Hi:

As far as I recall, no one has provided a horizontal barchart as a solution,
so here's one using lattice:

library(lattice)
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)
smw.f <- table(smw.dat)
barchart( ~ smw.f, horizontal = TRUE, xlim = c(0, 14),scales = list(axs =
'i'),
    col=rainbow(5), main="Survey answers", xlab="Responses" )

Given the lengths of the labels, it might be preferable to view them from
this perspective instead. dotchart() [dotplot() in lattice] would be a
viable alternative for displaying this discrete distribution, but its colors
aren't as pretty :)

HTH,
Dennis

On Fri, Aug 6, 2010 at 3:57 AM, Jim Lemon <jim@bitwrit.com.au> wrote:

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

	[[alternative HTML version deleted]]

