Reputation: 23
I need to total "how many responses contain X from column 1, y from column 2, and z from column 3". Column one is boolean, two is numerical (>=100), three is categorical. How do I write this code in R?
So far, I have this:
sample_data <-
sample_220 %>%
dplyr::sum(sample.column1==TRUE & sample.column2>=1000 & sample.column3=="Sample Institution")
Upvotes: 0
Views: 140
Reputation: 388982
There is no dplyr::sum
function. sum
function is in base R.
To get the count of rows which match the condition you can use the following.
result <- with(sample_220, sum(sample.column1 & sample.column2>=1000 & sample.column3=="Sample Institution"))
Since sample.column1
is already boolean we can avoid sample.column1 == TRUE
.
Upvotes: 1