[R] "untable" function

About this list Date view Thread view Subject view Author view

From: RINNER Heinrich (H.RINNER@TIROL.GV.AT)
Date: Mon 26 Feb 2001 - 21:38:37 EST


Message-ID: <C4D44AB4CB62D311BA6500041202E886264140@xms1.tirol.gv.at>

Dear R-users!

I am using R1.2.0 under Windows NT4.0, and have data of the following form:

> #simple example of data structure:
> x <- data.frame(group=LETTERS[1:3], class1=1:3, class2=4:6)
> x
  group class1 class2
1 A 1 4
2 B 2 5
3 C 3 6

I would like to convert this to a data.frame y of the following form:
> y
 group class counts
1 A class1 1
2 A class2 4
3 B class1 2
4 B class2 5
5 C class1 3
6 C class2 6

So what I'm looking for is something like an "untable"-function. Is there a
simple "natural" way for this in R, or will I have to loop through rows and
columns somehow (my "real world" data set consists of 279 rows/groups and
100 columns/classes)?

Heinrich.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:33 EST