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
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
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
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),
4 matches
Mail list logo