Getting the values for dependent variable in binary independent variable in R -
i have data frame named orf. trying work out coding on how calculate values dependent variable in binary independent variable e.g breed. table gives me number of breeds in each category. how go coding calculate instance 341 breed type 1 had 500 cases of disease. y here cases
table(orf$breed) 1 2 341 405 example: breed cases2012 2 0 1 0 2 8 2 73 2 0 2 26 2 0 2 45 1 0 2 22 1 0 1 0 2 0 2 6 1 539
this 1 of things there's million ways of doing in r.
here's how i'd in dplyr
library(dplyr) data %>% group_by(breed) %>% summarise(cases = sum(cases2012))
Comments
Post a Comment