[R] make dataframe from table

From: Boks, M.P.M. <M.P.M.Boks_at_umcutrecht.nl>
Date: Mon, 4 Feb 2008 14:59:00 +0100

Dear R-experts,    

I have got a dataframe:
ID disease
  V1 V2
1 p1 1
2 p1 3
3 p3 3
4 p3 5
5 p5 1  

>From which I extract a usefull table: affect


        1 3 5
  p1 1 1 0
  p3 0 1 1
  p5 1 0 0

I want to merge this with anotherdataframe: age
p1 23
p2 24
p3 23
p4 11
p5 45  

If have tried as.data.frame(affect) and other solutions to get the following comment going:
merge(age,affect, by.x=0, by.y=1)  

QUESTION: I can get the merging process going with the outcome of the table command.  

Any help would be great.  

R for windows v2.6.1  


data<-as.data.frame(matrix(c("p1","p1","p3","p3","p5",1,3,3,5,1),5,2)) age<-as.data.frame(matrix(c("p1","p2","p3","p4","p5",23,24,23,11,45),5,2 ))
merge(age,affect, by.x=0, by.y=1)    



        [[alternative HTML version deleted]]

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 Mon 04 Feb 2008 - 14:10:44 GMT

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 Mon 04 Feb 2008 - 17:30:11 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