On 08/06/2010 04:22 AM, yankeetilidie wrote:

Hello,

I am attempting to create a bar plot that contains a range of possible
response values on the x-axis of 1 to 5 and contains barplots for the number
of responses even in the event that there are 0 responses. For example, I
have a data set that contains values of 2, 3, 4, and 5 but I would also like
my graph to show that there are no 1's.

I have attached the resulting graph. The appropriate values should be 0 -
Strongly Disagree, 1 - Somewhat Disagree, 2 - Neutral, 7 - Somewhat Agree,
and 12 - Strongly Agree.

Hi Steve,
Given your labels, I would suggest the following:


smw.dat<-factor(rep(c("Somewhat Disagree","Neutral",
 "Somewhat Agree","Strongly Agree"),c(1,2,7,12)),
 levels=c("Strongly Disagree","Somewhat Disagree","Neutral",
 "Somewhat Agree","Strongly Agree"),ordered=TRUE)
library(prettyR)
smw.freq<-freq(smw.dat,display.na=FALSE)
library(plotrix)
barp(smw.freq,names.arg=levels(smw.dat),staxx=TRUE,
 col=rainbow(5),main="Survey answers",xlab="Responses")

Jim

______________________________________________
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.

Reply via email to