builds many histograms and arranges them around a circle to save space.

Usage

polarHistogram(df, family = NULL, columnNames = NULL, binSize = 1, spaceItem = 0.2,
  spaceFamily = 1.2, innerRadius = 0.3, outerRadius = 1, guides = c(10, 20, 40,
          80), alphaStart = -0.3, circleProportion = 0.8, direction = "inwards", familyLabels = FALSE)

Arguments

df
a data frame containing the data
family
list fro defining families
columnNames
user-defined columns names
binSize
width of the bin. Should probably be left as 1, as other parameters are relative to it.
spaceItem
space between bins
spaceFamily
space between families
innerRadius
radius of inner circle
outerRadius
radius of outer circle. Should probably be left as 1, as other parameters are relative to it.
guides
a vector with percentages to use for the white guide lines
alphaStart
offset from 12 o'clock in radians
circleProportion
proportion of the circle to cover
direction
whether the increasing count goes from or to the centre.
familyLabels
logical. Whether to show family names

Description

The data frame is expected to have at least four columns: family, item, score and value. The three first columns are categorical variables, the fourth column contains non-negative values. See the vignette for an example. Each bar represents the proportion of scores for one item. Items can be grouped by families. The resulting graph can be busy and might be better off saved as a pdf, with ggsave("myGraph.pdf").

Value

a ggplot object

Examples

library(reshape2) set.seed(42) nFamily<-20 nItemPerFamily<-sample(1:6,nFamily,replace=TRUE) nValues<-3 randomWord<-function(n,nLetters=5) replicate(n,paste(sample(letters,nLetters,replace=TRUE),sep='',collapse='')) df<-data.frame( family=rep(randomWord(nFamily),nItemPerFamily), item=randomWord(sum(nItemPerFamily),3)) df<-cbind(df,as.data.frame(matrix(runif(nrow(df)*nValues),nrow=nrow(df),ncol=nValues))) df<-melt(df,c("family","item"),variable.name="score") # from wide to long print(head(df))
family item score value 1 xdzyc jko V1 0.9799076 2 xdzyc psk V1 0.6438641 3 xdzyc xzg V1 0.5825784 4 xdzyc sxp V1 0.6158710 5 xdzyc qyw V1 0.9251403 6 xdzyc pvc V1 0.3900229
p<-polarHistogram(df,familyLabel=FALSE) print(p)

Author

Christophe Ladroue