Thanks for the great helps from David, Jim and Liviu. It solved my problem.
Appreciated! On Thu, Sep 1, 2011 at 11:01 AM, David Winsemius <dwinsem...@comcast.net>wrote: > > On Sep 1, 2011, at 1:53 PM, Changbin Du wrote: > > HI, Dear R community, >> >> I want to split a data frame by using two variables: let and g >> >> x = data.frame(num = >>> >> c(10,11,12,43,23,14,52,52,12,**23,21,23,32,31,24,45,56,56,76,**45), let = >> letters[1:5], g = 1:2) >> >>> x >>> >> num let g >> 1 10 a 1 >> 2 11 b 2 >> 3 12 c 1 >> 4 43 d 2 >> 5 23 e 1 >> 6 14 a 2 >> 7 52 b 1 >> 8 52 c 2 >> 9 12 d 1 >> 10 23 e 2 >> 11 21 a 1 >> 12 23 b 2 >> 13 32 c 1 >> 14 31 d 2 >> 15 24 e 1 >> 16 45 a 2 >> 17 56 b 1 >> 18 56 c 2 >> 19 76 d 1 >> 20 45 e 2 >> >> I tried the following: >> >> xs = split(x,x$g*x$let) >> > > Probably > > xs = split(x,list(x$g,x$let)) > >> >> *Warning message: >> In Ops.factor(x$g, x$let) : * not meaningful for factors* >> >> >> xs = split(x,c(x$g*x$let)) >> >> *Warning message: >> In Ops.factor(x$g, x$let) : * not meaningful for factors >> * >> >> Can someone give some hints? >> >> Thanks! >> >> >> -- >> Sincerely, >> Changbin >> -- >> >> [[alternative HTML version deleted]] >> >> ______________________________**________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<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. >> > > David Winsemius, MD > West Hartford, CT > > -- Sincerely, Changbin -- Changbin Du Data Analysis Group, Affymetrix Inc 6550 Emeryville, CA, 94608 [[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.