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 =
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
-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
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