Wow, I'm getting confused...The syntax Petr suggested does what I wanted, but things are stille wrong...Maybe a bug? Let me explain.

I got two vectors:

x = c(3, 3, 3, 4, 3, 4, 3, 4, 3, 4)

y = c(5, 2, 5, 5, 2, 2, 5, 5, 4, 2)

then I do the barplot you suggest

barplot(rbind(table(x), table(y)), beside=T)

but things are wrong(there is no bar for catagory "3") and I get an error message:
Warning message: number of columns of result
not a multiple of vector length (arg 1) in: rbind(table(Quest1), table(Quest2))


Any ideas?

Petr Pikal wrote:

Hi

If I understand correctly

barplot(rbind(table(x), table(y)), beside=T)

does what you want.

Cheers
Petr



On 18 Feb 2005 at 7:51, T Petersen wrote:



Almost. Catagories aren't stacked - I would like to see that x has 2
instances of "1" while y has 1 instance of "1". What's more, there are
now TWO distinct barplots - the left one shows x, while the right one
shows y. I could live with that, but what I'd ideally want is to have
x and y beside each other for EACH catagory - so for catagory "1" you
could see taht there are more x's than y's (two x's versus one y). But
thanks for the help

Mulholland, Tom wrote:



barplot(matrix(c(x,y),ncol = 2),beside=T)

Does this help

?barplot notes

height: either a vector or matrix of values describing the bars which
        make up the plot.  If 'height' is a vector, the plot
        consists of a sequence of rectangular bars with heights
        given by the values in the vector.  If 'height' is a matrix
        and 'beside' is 'FALSE' then each bar of the plot
        corresponds to a column of 'height', with the values in the
        column giving the heights of stacked "sub-bars" making up
        the bar.  If 'height' is a matrix and 'beside' is 'TRUE',
        then the values in each column are juxtaposed rather than
        stacked.






-----Original Message-----
From: T Petersen [mailto:[EMAIL PROTECTED]
Sent: Friday, 18 February 2005 1:35 PM
To: Kevin Wang
Cc: [email protected]
Subject: Re: [R] Barplot - Can't figure it out


Ups, it should of course be barplot() in my mail, not boxplot:-)

Kevin Wang wrote:





Hi,

T Petersen wrote:





Hi,

I have two catagorical vectors like this;

x = c(1, 2, 4, 2, 1)
y = c(2, 4, 2 ,4, 1)

I want to set up a barplot with the catagories 1-4



horizontally and



number of occurances vertically for each vector x,y. I've tried

boxplot(table(x,y), beside=T)

and

boxplot(c(x,y), beside=T)




Have you tried barplot(), instead of boxplot()???

Cheers,

Kev





______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html






______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html





______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html



Petr Pikal [EMAIL PROTECTED]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to