-3

I'm using R, trying to use data I've been given to plot a boxplot. One of the categories is "sex", with (obviously) either "M" or "F". How do I exclude females, so I can use the male data to create a boxplot? I'm new to R, any help would be appreciated!

EDIT: Okay, I managed to make a vector(??) only including male data using newdata<-subset(olympic, sex=="M"). Now how do I do the same but with two subsets of a different category of continous data? Is it similar notation? (E.g. say the category is "hair" with different colours, and I want "blonde" and "ginger")

2 Answers2

1

try to boxplot on male_data

male_data <- data[data$sex == "M",]
cccmir
  • 953
  • 6
  • 12
1

Use boxplot(, subset = )

I don't have data, so only direct you to subset argument.

I think as a general guideline, check documentation page of an R function first before asking on SO. R functions, especially those producing summary plots, are very powerful as they often have many arguments offering very flexible options. See `?boxplot' in this case.

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248