There are 34 variables in my dataset. I am trying to make boxplot for each variable. I also want to use log Y-axis. Here is my R code:
boxplot(mydata,log="y")
#Warning message:
#In plot.window(xlim = xlim, ylim = ylim, log = log, yaxs = pars$yaxs) :
# nonfinite axis limits [GScale(-inf,3.61878,2, .); log=1]
Could you please help me how to correct it? Also, I need all variables name in this one figure.
The problem is that in your "mydata" there are variables containing "0" values. And for zero values the logaritmic rescaling of y-axis provides "-Inf"
log(0)
[1] -Inf
# I tried to reproduce your example:
library(datasets)
data(airquality)
x <- airquality
boxplot(x, log="y") # works fine!
# Now I'm going to manipulate the data by changing the first value of dataset.
x[1,1] <- 0
boxplot(x, log="y")
Warning message:
In plot.window(xlim = xlim, ylim = ylim, log = log, yaxs = pars$yaxs) :
nonfinite axis limits [GScale(-inf,2.52375,2, .); log=1]
# To solve this problem I would suggest to replace all "0"-values to
# "1" values. Why? Because after you want to build log-values, and log(1)=0
x[(x == 0)] <- 1
boxplot(x, log="y") # It works fine!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With