Re: [R] Need help with table() and apply()

2011-11-20 Thread Stuart Luppescu
On 日, 2011-11-20 at 17:43 -0500, jim holtman wrote: > It might be good if you told us the problem you are trying to solve. > Why do you have factors in the dataframe? Can you just have the > values? Do you want to count the 'levels' of the factors in a row, or > do you want to count the numeric t

Re: [R] Need help with table() and apply()

2011-11-20 Thread jim holtman
It might be good if you told us the problem you are trying to solve. Why do you have factors in the dataframe? Can you just have the values? Do you want to count the 'levels' of the factors in a row, or do you want to count the numeric they represent (in your case it is the same, so I wonder why

Re: [R] Need help with table() and apply()

2011-11-20 Thread jim holtman
The answer to your question as to why you had to convert back to factors is that you "undid" the factors when you did the 'cbind' to create the dataframe. Here is what you should have done: > df <- data.frame(rating.1 , rating.2 , rating.3 , rating.4 , + rating.5 , rating

[R] Need help with table() and apply()

2011-11-20 Thread Stuart Luppescu
Hello, I am having trouble getting counts of values in rows of a data frame. I'm trying to use apply, but it's not working. This gives a sample of the kind of data I'm working with: rating.1 <- factor(sample(1:4, size=10, replace=T), levels=1:4) rating.2 <- factor(sample(1:4, size=10, replace=T),