try this: > x <- c("A", "A", "B", "A") > x.t <- table(x) > x.t x A B 3 1 > x.tw <- paste("W", x.t, sep='') > names(x.tw) <- names(x.t) > x.tw A B "W3" "W1" >
On Tue, Jan 5, 2010 at 6:38 PM, <laura....@utoronto.ca> wrote: > Hi, > > I have generated a table of counts, and now need to add a prefix to the > counts. > > #count KO occurrences > KO_occur = table(groupKOIDs) #where groupKOIDs is a vector of characters > > e.g., > > if groupKOIDs = c("A", "A", "B", "A") > then > KO_occur would look like this: > > A B > 3 1 > > and I need to add a W to the front of the counts: > > A B > W3 W1 > > If anyone has ideas for me as to how to approach this, I'd be very > grateful! > > cheers, > Laura > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.