[R] "untable" function

RINNER Heinrich H.RINNER at TIROL.GV.AT
Mon Feb 26 12:38:37 CET 2001


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



More information about the R-help mailing list