scoop doest give the same outcome

29 views Asked by At
  nrow(filter(dataframe, fracture_type_1 == 1)) +
  nrow(filter(dataframe, fracture_type_2 == 1)) +
  nrow(filter(dataframe, fracture_type_3 == 1)) +
  nrow(filter(dataframe, fracture_type_4 == 1)) +
  nrow(filter(dataframe, fracture_type_5 == 1)) 

I want to make :

nrow(filter_at(dataframe, vars(starts_with("fracture_type_")), any_vars(.==1)))

but they dont give the same outcome

1

There are 1 answers

0
Ronak Shah On BEST ANSWER

If you want an output which is similar to your first attempt it would be :

library(dplyr)

dataframe %>%
    summarise(total = sum(select(., starts_with("fracture_type_")) == 1))