1
votes
> B<-subset(olympic,sport=="basketball")
> BM<-subset(B,sex=="M"
+ )
> boxplot(BM$height)

Error in plot.window(xlim = xlim, ylim = ylim, log = log, yaxs = pars$yaxs):
need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

This is what happened when I try to plot the graph. I'm new to R.

2
What effort have you made to investigate the issue? If I search for the second line of the error, I get this, this, this and this. - Roman Luštrik
@XiaohuiZhu If you post a working example (that is, a dataset that throws the error), we can better help you. As it is, we are guessing. - user1322720
What is the output from BM$height ? - user1322720
I want to make boxplot between male basketball's height, and male football player's height, and the format of the data is like "height" "sport" "sex" "1" 170 "Judo" "M" "2" 193 "Athletics" "M" "3" 187 "Athletics" "M" "4" NA "Boxing" "M" "5" 178 "Athletics" "F" "6" 182 "Handball" "M" "7" 182 "Rowing" "F" "8" 187 "Football" "M" "9" 190 "Athletics" "M" "10" 170 "Boxing" "M" and so on. so BM$height means basketballmale $height - Melisa Sun
All your examples sports start with an upper case letter. But in your example, basketball starts with a lower case letter. R is case sensitive. Suspect BM is empty. You can run the two subset commands together subset(df, condition1 & condition2) - Richard Telford

2 Answers

0
votes

Just add ylim=c(0,300)) to your code

-1
votes

I see nothing wrong in the command though it can be shortened to:

> BM <- subset(olympic,sport=="basketball" & sex == 'M')

> boxplot(BM$height)

The error that you are getting might be because of the fact that data.frame BM has zero rows.

I would recommend you to please check the case of values for sport (i.e. whether in the dataset, 'Basketball' is present and you are searching for 'basketball')