[R] Factors to Columns

From: David martin <vilanew_at_gmail.com>
Date: Fri, 20 May 2011 11:49:19 +0200


> str(data)

'data.frame': 250 obs. of 3 variables:

  $ student: chr  "A" "B" "C" "D" ...
  $ data   : num  20.2 20.4 22.5 22.1 23.3 ...
  $ param   : Factor w/ 4 levels "AGE","SCHOOL",..: 1 1 1 1 1 1 1 1 1 1


Hi , i would like to split the dataframe so that each level of param is a column
At the end it should look like

	AGE	SCHOOL ...
A	20.2	20.4
B	22.5	22.1
C	23.1	24
D	22	22.8

..

is i use that contingency table:
table(data$student,data$param) i will have such a similar table of what i want, except that i don't need counts but real data.

How can i split levels of the dataframe into columns ??

thanks



R-help_at_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. Received on Fri 20 May 2011 - 09:51:56 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 20 May 2011 - 10:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive