Skip to content
Prev 170033 / 398506 Next

Loop on characters

megh -
    The best way to organize similar objects in R is to
put them into a list.  If you keep this in mind when you're
first organizing your data, it's no harder than giving each object
a separate name.  For example
The reason that this is a good idea in R is that functions
like sapply, lapply, and mapply automatically operate on each
element of a list, and return the answer in a suitable R object. 
(Note that in your example, you would get an error because you 
hadn't defined count1.  And why should you?)

So the answer you want is
[1]  4  6 52

Hope this helps.
                                        - Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Tue, 10 Feb 2009, megh wrote: