I am trying to learn how to reshape my data set.  I am new to R, so please
bear with me.  Basically, I have the following data set:

site<-c("A","A","B","B")
bug<-c("spider","grasshopper","ladybug","stinkbug")
count<-c(2,4,6,8)
myf <- data.frame(site, bug, count)
myf

  site         bug count
1    A      spider     2
2    A grasshopper     4
3    B     ladybug     6
4    B    stinkbug     8

This means that in site A, I found 2 spiders and 4 grasshopper.  In site B,
I found 6 ladybugs and 8 stinkbugs.

I would like to change the df to aggregate the site column and make the bugs
columns so it arranged like this:

  site spider grasshopper ladybug stinkbug
1    A      2           4       0        0
2    B      0           0       6        8


--
View this message in context: 
http://r.789695.n4.nabble.com/need-help-reshaping-table-using-aggregate-tp4634014.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to