Re: [R] Simple use of dcast (reshape2 package)

2013-01-23 Thread Patrick Connolly
On Tue, 22-Jan-2013 at 08:30AM -0500, Ista Zahn wrote: |> Hi, |> |> ID is not the value column. Your casting call should be |> |> dcast(aa, ... ~ Target, value.var = "Eaten") Thanks for that illumination. That does exactly what I wanted. I knew there were many ways of achieving the result, bu

Re: [R] Simple use of dcast (reshape2 package)

2013-01-22 Thread arun
2  10 A.K. - Original Message - From: Patrick Connolly To: R-help Cc: Sent: Tuesday, January 22, 2013 4:23 AM Subject: [R] Simple use of dcast (reshape2 package) Suppose I have a small dataframe > aa     Target Eaten ID 50      TPP    0  1 51      TPP    1  2 52      TPP    3  3 53      TPP

Re: [R] Simple use of dcast (reshape2 package)

2013-01-22 Thread Ista Zahn
Hi, ID is not the value column. Your casting call should be dcast(aa, ... ~ Target, value.var = "Eaten") Best, Ista On Tue, Jan 22, 2013 at 4:23 AM, Patrick Connolly wrote: > Suppose I have a small dataframe > >> aa > Target Eaten ID > 50 TPP 0 1 > 51 TPP 1 2 > 52

Re: [R] Simple use of dcast (reshape2 package)

2013-01-22 Thread Gerrit Eichner
Hi, Patrick, I think (with reshape from the stats package) reshape( aa, idvar = "ID", v.names = "Eaten", timevar = "Target", direction = "wide") does the trick (followed by renaming the columns of the resulting data frame). Hth -- Gerrit On Tue, 22 Jan 2013, Patrick Connolly wr

Re: [R] Simple use of dcast (reshape2 package)

2013-01-22 Thread D. Rizopoulos
you could try the following: DF <- read.table(textConnection(" Target Eaten ID 50 TPP 0 1 51 TPP 1 2 52 TPP 3 3 53 TPP 1 4 54 TPP 2 5 50.1GPA 9 1 51.1GPA11 2 52.1GPA 8 3 53.1GPA 8 4 54.1GPA10 5"),

[R] Simple use of dcast (reshape2 package)

2013-01-22 Thread Patrick Connolly
Suppose I have a small dataframe > aa Target Eaten ID 50 TPP 0 1 51 TPP 1 2 52 TPP 3 3 53 TPP 1 4 54 TPP 2 5 50.1GPA 9 1 51.1GPA11 2 52.1GPA 8 3 53.1GPA 8 4 54.1GPA10 5 And I want to reshape it int