Re: [R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
To answer my own post, and for the archives (hopefully not that anyone has to repeat what I had to do ;-), after much hair-pulling , frowning at the screen and general dumb headedness the following slab of R code achieves the results I wanted. It isn't elegant but does a job. msr <- function(x) {

Re: [R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
Apologies, Jim Holtman has pointed out a couple of problems/queries with my original email that I would like to make clear. Firstly, I introduced a typo when trying to be helpful. In my email below, I had incorrectly typed out one of the species codes I would count: 1000 16220602 2011 240

[R] Counting/processing a character vector

2009-02-18 Thread Gavin Simpson
Dear List, I have a data set stored in the following format: > head(dat, n = 10) id sppcode abundance 1 10307 1000 1 2 10307 16220602 2 3 10307 2000 5 4 10307 2011 2 5 10307 2400 1 6 10307 402183 7 10307 40210102