0

I want to compare between male basketball player's height and male football players's height by doing box plot. but there's some error occurred when plotting it.I read the data first

**> olympic<-read.table(file="olympic_height.txt", header=T)

names(olympic) [1] "height" "sport" "sex"
olympic 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**

then I type these commands but there's mistake

                                                                         **> 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 **

I tried another way but still doesn't work

**> BM <- subset(olympic,sport=="basketball" & 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**

the same problem.I really don't know what is wrong? there's thousands of data set by the way not just those up.

Melisa Sun
  • 11
  • 1
  • 1
  • 2
  • http://stackoverflow.com/a/5963610/2747709 - please ask a reproducible R question! – infominer Apr 11 '16 at 19:43
  • 1
    Possible duplicate of [How to plot a bloxplot in R with subsets](http://stackoverflow.com/questions/36409627/how-to-plot-a-bloxplot-in-r-with-subsets) R is case-sensitive. So type the variable names and values exactly as displayed. – infominer Apr 11 '16 at 19:45
  • I've tried the method in my computer but still doesn't work – Melisa Sun Apr 11 '16 at 20:07
  • Edit your post and add the result of `dput(BM)` or the smaller `dput(head(BM))`, if `boxplot(head(BM$height))` reproduces the error, too. In addition, it would be nice to reference your previous question http://stackoverflow.com/questions/36528416/r-software-making-boxplot-need-finite-ylim-value so that people can see what did not work. – lukeA Apr 11 '16 at 20:11
  • thank you for mentioning my previous question. > BM<- subset(B,sex=="M") > boxplot(head(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 > dput(BM)<- subset(B,sex=="M") Error in dput(BM) <- subset(B, sex == "M") : could not find function "dput<-" > but I tried, still same problem – Melisa Sun Apr 11 '16 at 20:26
  • @XiaohuiZhu type this and check again `BM <- subset(olympic, Sport == "Basketball" & Sex == "M")` and then `boxplot(BM$Height)`. Note the capitalization, as R is case-sensitive. – infominer Apr 11 '16 at 20:31

0 Answers0