Dear R wizes,
 
I have a data.frame of species abundances with column names consisting
of 4 letter codes then an underscore and a number like this:
 
abco_1, abco_2, abco_3, psm_1, psme_2, psme_3, etc.
 
I would like to get an identifier for all the abco, and psme and other
species etc.
 
I used 
 
        spec.fact<-substring(names(spec.count),1,4)
 
To make a vector of the first 4 letters of each name. I tried using 
        spec.groups <- unique(spec.fact)
 
and then matching    
 
        pmatch(spec.groups[1],spec.fact)
 
to get out the indexes of all the columns that match the second unique
value, i.e what are the column number for all the abco columns.  Then I
could make a temporary data.frame of just the abco columns. I could loop
through the unique vector spec.groups to do this for each group and
perform the operations I need to on each individual mini-dataframe.
Unfortunately the matching doesn't work. Any suggestions?
 
Ken
 
 
 

Kenneth B. Pierce Jr.

Research Ecologist

Landscape Ecology, Modeling, Mapping and Analysis Team 

PNW Research Station - USDA-FS 

3200 SW Jefferson Way,  Corvallis,  OR 97331 

ken.pierce@oregonstate.edu

541 750-7393 

http://www.fsl.orst.edu/lemma/gnnfire

 

	[[alternative HTML version deleted]]

