I'm creating a stacked bar chart using the likert command in the HH package. My data are in a data frame, with two numeric variables and a categorical variable, I can't get likert to use the column containing the categorical variable as a my y axis label.
Here is a quick example: library(HH) #my data are: df<-data.frame(as.character(cat=c("group1","group2","group3","group4", "group5")),males=c(20,30,45,12,5),females=c(35,23,32,8,5)) #make a pyramid Likert chart p<-likert(df) as.pyramidLikert(p) It tries to plot three variables here when I just want two. I think I understand what is happening - my categorical variable is treated as a factor and I think it gets inserted as an integer into the matrix which the command derives from my data fame, to make the plot with(?) It's then used as a variable to be plotted just like the other two variables. what I don't get is how the example given in the package does something differently, which is how I want mine to work. ## Population Pyramid data(USAge.table) USA79 <- USAge.table[75:1, 2:1, "1979"]/1000000 PL <- likert(USA79, main="Population of United States 1979 (ages 0-74)", xlab="Count in Millions", ylab="Age", scales=list( y=list( limits=c(0,77), at=seq(1,76,5), labels=seq(0,75,5), tck=.5)) ) PL as.pyramidLikert(PL) This does exactly what I'm trying to achieve. here the two population counts are plotted in the likert plot and the age groups in the first columns are used as labels. I can't work out why in my example the age group variable is not used in the same way as the in my plot in the same way as the agegroups in this example, other than the example takes it's data from a table and mine is coming from a data frame. The end point I want is a stacked Likert bar chart based on a data frame where the column containing the description of my groups is used as the y axis labels and the other two columns are used to draw the bars. I'm sure I'm missing a simple solution. any help gratefully received. Gavin. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.