Hello,
I have a growing dataset that I am really struggling to condense into a usable form. I am doing field work that requires me repeatedly visiting sites throughout a year, and doing 10 sweeps of the sites each time. So my data is inputted as "Site 1" on "3-July", and "Sweep 1", repeat through sweep 10 for each visit.
On each sweep we count the number of different inverts we find. I need to be able to combine those counts per site, but keep the different dates separate.
> site <- c("A1","A1","A2","A2","A1","A1","A2","A2")
> date <- c("7/31","7/31","7/31","7/31","8/29","8/29","8/29","8/29")
> bugs <- c(10,10,20,20,5,5,10,10)
> data <- data.frame(site,data,bugs)
In the small dataset above, I want to combine the number of bugs based on site and date, e.g. sum the number of bugs in the two "A1" on "7/31" columns so that it just says "Site = A1, Date = 7/31, bugs =20", as the data frame below would show:
> site <- c("A1","A2","A1","A2")
> date <-c("7/31","7/31", "8/29", "8/29")
> bugs <-c(20, 40, 10, 20)
> data <- data.frame(site,date,bugs)
Thank you for any advice.