Skip to content
Prev 342808 / 398506 Next

Convert some columns of List to dataframe R

On Sun, Aug 3, 2014 at 5:12 PM, Zilefac Elvis <zilefacelvis at yahoo.com> wrote:
Try rbind_all in the dplyr package together with the dcast() function
in the reshpae2 package

output1 <- rbind_all(as.list(lst3));
realOutput <- dcast(output1, Year ~ Site, value.var="x");

Example transcript:
+     x = 33.1), .Names = c("Year", "Site", "x"), row.names = c(NA,
+ -1L), class = "data.frame"), structure(list(Year = 2001L, Site =
structure(1L, .Label = "G102", class = "factor"),
+     x = 34), .Names = c("Year", "Site", "x"), row.names = c(NA,
+ -1L), class = "data.frame"))
Year Site    x
1 2001 G101 33.1
2 2001 G102 34.0
Warning message:
In rbind_all(lst3) : Unequal factor levels: coercing to character
Year G101 G102
1 2001 33.1   34
Sorry for the extra reply.  60 hour work weeks and 61 years of age
don't mix well. Back to watching Beakman on Netflix.