Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

R: How to print boxplot, conditioned on another variable? I have a dataset calle

ID: 3270534 • 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)