Re: [R] contingency table on data frame

2008-01-22 Thread John Kane
It is not a good idea to use "sample' when building an example like this! Running the code does not give the example dataframe. This is crude but it will do what you want. x <- " Z Y X 1 4 Yes 2 1 No 3 2 Perhaps 4 3 Yes 5 4 No 6 5 No 7 1 Ye

Re: [R] contingency table on data frame

2008-01-22 Thread Domenico Vistocco
Karin Lagesen wrote: > I am sorry if this is a faq or tutorial somewhere, but I am unable to > solve this one. > > What I am looking for is a count of how many different > categories(numbers in this case) that appears for a given factor. > > Example: > > >> l <- c("Yes", "No", "Perhaps") >> x <-

[R] contingency table on data frame

2008-01-22 Thread Karin Lagesen
I am sorry if this is a faq or tutorial somewhere, but I am unable to solve this one. What I am looking for is a count of how many different categories(numbers in this case) that appears for a given factor. Example: > l <- c("Yes", "No", "Perhaps") > x <- factor( sample(l, 10, replace=T), level