Home > OS >  summarise() in R by specific observations
summarise() in R by specific observations

Time:02-15

I am trying to gather summary statistics of a variable (diffdays) when the variable "disease" is equal to Malaria.

My code for this is:

summary(deathdata$diffdays, deathdata$disease == "Malaria")

This doesn't seem to be working the way I'd like but am I close? Any help is appreciated.

CodePudding user response:

I don't have access to your data but using the built-in mtcars data I would summarize mpg with summary(mtcars$mpg). If I wanted to limit my summary to just those cars with six cylinders I'd subset the data in my call to summary: summary(mtcars[mtcars$cyl == 6, ]$mpg).

  • Related