Reputation: 151
I am trying to create a count of as a first step to calculate a percent cover for each category. The code below has worked before, but is no longer working.
I have read other posts on SO and none of them seem to capture the problem I'm experiencing.
Here is a reproducible example of what I'm trying to do:
library(dplyr)
cover_data_test<- data.frame( site=c('cram','khq','k50'),
treatment=c('exc','out','exc'),
season=c('fall','spring','fall'),
transect=c(1,1,1),
point=c(1,2,3),
ground=c('b','l','pb')
)
View(cover_data_test)
groundcover_test<- cover_data_test%>%
group_by(season,site,treatment,transect)%>%
count(ground)
I am still getting this error with the above example:
"Error in FUN(X[[i]], ...) : object 'b' not found"
Any ideas about what might be going on?
Upvotes: 2
Views: 6650
Reputation: 151
The conflicts()
function helped me get to the bottom of it! "count" was listed as a conflict so I edited the code to be
r
groundcover_test<- cover_data_test %>%
group_by(season,site,treatment,transect)%>%
dplyr::count(ground)
Adding the double colon operator dplyr::
allowed it to run as expected. Thanks again!
Upvotes: 13