[R] problem coercing truncated character vector to levels

From: Pierce, Ken <ken.pierce_at_oregonstate.edu>
Date: Wed 20 Sep 2006 - 22:42:51 GMT

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  


To make a vector of the first 4 letters of each name. I tried using

        spec.groups <- unique(spec.fact)  

and then matching  


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?  


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


541 750-7393


        [[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Sep 21 08:46:13 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 20 Sep 2006 - 23:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.