I have a data frame, a reproducible example is:
structure(list(Events = c("a", "a", "a", "b", "b", "b", "c",
"c", "c", "c"), Locations = c("Loca1", "Loca2", "Loca3", "Loca4",
"Loca5", "Loca6", "Loca7", "Loca8", "Loca9", "Loca10"), Coll = c(78115.68,
58361.86, 37409.54, 228922.82, 192700.77, 121201.98, 53941.03,
53065.56, 46271.9, 211083.11)), .Names = c("Events", "Locations",
"Coll"), class = "data.frame", row.names = c(NA, 10L))
It looks like this:
Events Locations Coll
1 a Loca1 78115.68
2 a Loca2 58361.86
3 a Loca3 37409.54
4 b Loca4 228922.82
5 b Loca5 192700.77
6 b Loca6 121201.98
7 c Loca7 53941.03
8 c Loca8 53065.56
9 c Loca9 46271.90
10 c Loca10 211083.11
I am trying to create a nested summary table where I want Events as Columns and Locations and Coll Values as Rows. My expected output is:
a b
Locations Coll Locations Coll
Loca1 78115.68 Loca4 228922.82
Loca2 58361.86 Loca5 192700.77
Loca3 37409.54 Loca6 121201.98
I tried using reshape2 recast function...but it fills the table with NA values which I don't want. Any thoughts would be very helpful.