Dear S-Plus user,
I have a data set with 7000 records containing the following variables;
size, species name, and family name of trees in the forest. Most family
has more than one species. I am trying to calculate the number of
individual and number of species in each, but only succeed for the first
calculation (i.e. number of trees by family using the tapply command).
for example;
attach(file.dat)
tapply( size,family,length)
For the second calculation, I would like to find the number of unique
species present in each family.
The command tapply(species,family,length) showed the total number of
species which include repeated species name. I've browsed unique command
in help page, with the thought that by creating another file containing
unique species along with other variables, i.e. family and size. Then use
tapply to create the required data output.But the unique command only apply
to a vector instead of a data frame. Is this correct? How can I subset a
data frame which will produce the unique species and related family
variable?
I've also tried using the following command but the results is not what I
expected.
tapply(unique(spp),family[unique(spp)] ,length)
Any assistance would be appreciated. Thanks.
Abd Rahman Kassim
Hill Forest Silviculture
Forest Research Institute Malaysia (FRIM)
Kepong 52109
Kuala Lumpur
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|