[R] complex splits

Pierre Kleiber pkleiber at honlab.nmfs.hawaii.edu
Fri Aug 16 02:30:08 CEST 2002


    split(d$splitcol,paste(d$col1,d$col2))

will give you vectors as elements of a list based on possible
combinations of col1 and col2.  Is that what you're after?
   Cheers, Pierre



Tim Wilson wrote:

> Hi everyone,
> 
> I'm having trouble figuring out how to split a dataframe more than once.
> 
> Let's say I have a dataframe d with a certain column called splitcol
> composed of four possible ordinal values.  The same dataframe has
> two other columns, col1 and col2, that have one of two possible values
> each. I'd like to split d$splitcol based on col1 and col2 so I can report
> frequencies of the subgroups.
> 
> So if col1 and col2 can each have two different values, after splitting
> I should have four vectors based on d$splitcol.
> 
> Can I do this in one step, or do I need to do some intermediate
> splitting?
> 
> -Tim
> 
> 


-- 
-----------------------------------------------------------------
Pierre Kleiber             Email: pkleiber at honlab.nmfs.hawaii.edu
Fishery Biologist                     Tel: 808 983-5399/737-7544
NOAA FISHERIES - Honolulu Laboratory         Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396
-----------------------------------------------------------------
  "God could have told Moses about galaxies and mitochondria and
   all.  But behold... It was good enough for government work."
-----------------------------------------------------------------


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list