Both ways are doing well the job. Nice!
Thanks again!
--
View this message in context:
http://r.789695.n4.nabble.com/transpose-a-data-frame-according-to-a-specific-variable-tp4702971p4703007.html
Sent from the R help mailing list archive at Nabble.com.
_
library(tidyr)
spread(DF,Year,Day)
> On 09 Feb 2015, at 16:47, jeff6868 wrote:
>
> finalDF <-
> data.frame(id=c("A","B","C"),"2000"=c(NA,NA,164),"2001"=c(120,NA,99),
> "2002"=c(90,18,48),"2003"=c(54,217,NA),"2004"=c(NA,68,NA))
signature.asc
Description: Message signed with OpenPGP using G
One way is to use the reshape2 package:
library(reshape2)
dcast(DF, id ~ Year, value.var = "Day")
Dennis
On Mon, Feb 9, 2015 at 7:47 AM, jeff6868
wrote:
> Dear R-users,
>
> I would like to transpose a large data.frame according to a specific column.
> Here's a reproductible example, it will be
3 matches
Mail list logo