[R] Summarizing factor data in table?

2005-04-26 Thread Andy Bunn
I have a very simple query with regard to summarizing the number of factors present in a certain snippet of a data frame. Given the following data frame: foo - data.frame(yr = c(rep(1998,4), rep(1999,4), rep(2000,2)), div = factor(c(rep(NA,4),A,B,C,D,A,C)), org =

Re: [R] Summarizing factor data in table?

2005-04-26 Thread Tony Plate
Do you want to count the number of non-NA divisions and organizations in the data for each year (where duplicates are counted as many times as they appear)? tapply(!is.na(foo$div), foo$yr, sum) 1998 1999 2000 042 tapply(!is.na(foo$org), foo$yr, sum) 1998 1999 2000 442

RE: [R] Summarizing factor data in table?

2005-04-26 Thread Andy Bunn
-Help Subject: Re: [R] Summarizing factor data in table? Do you want to count the number of non-NA divisions and organizations in the data for each year (where duplicates are counted as many times as they appear)? tapply(!is.na(foo$div), foo$yr, sum) 1998 1999 2000 042

Re: [R] Summarizing factor data in table?

2005-04-26 Thread Gabor Grothendieck
Subject: Re: [R] Summarizing factor data in table? Do you want to count the number of non-NA divisions and organizations in the data for each year (where duplicates are counted as many times as they appear)? tapply(!is.na(foo$div), foo$yr, sum) 1998 1999 2000 0 4 2 tapply(!is.na