R: How to print boxplot, conditioned on another variable? I have a dataset calle
ID: 3297146 • Letter: R
Question
R: How to print boxplot, conditioned on another variable?
I have a dataset called "diabetes". I need to print a boxplot of the stabalized glucose, conditioning on gender. What is the R code to make a boxplot of glucose levels for both males and females?
"diabetes$stab.glu" is a column of the dataset, consisting of numbers from about 60~300 (stabilized glucose levels)
"diabetes$gender" is either "male" or "female"
More info on the dataset here: https://www.rdocumentation.org/packages/faraway/versions/1.0.7/topics/diabetes
Explanation / Answer
R-code is :
install.packages("lattice")
library(lattice)
data(diabetes)
attach(diabetes)
gender=factor(gender)
bwplot(stab.glu~gender,data=diabetes)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.