0

The beanplot function keeps showing me this error:

Warning message:
In max(unlist(dens["y", ])) :
  no non-missing arguments to max; returning -Inf

It has been working fine up until now. I'm really new at R, and I've been trying to work out what the problem is, but no luck so far. Any suggestions?

This is my code:

> data$Treat <- factor(data$Treat, levels = c("Parthenogenetic", "Monoandrous", "Polyandrous"))
> beanplot(Mort~Treat, data=data, col=list("firebrick", "deepskyblue3", "chartreuse4"),
+          ylab="Number of days", xlab="Reproductive mode",
+          las=1, ylim=c(0,80), cutmin = -Inf, cutmax = Inf, log="")
Morgane
  • 11
  • 2
  • You should generally provide a minimal reproducible example as explained [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). How does `str(data)` look like? – tobiasegli_te Nov 08 '17 at 13:11

1 Answers1

0

Use labels not levels when you need to rename the categories of Treat.

set.seed(1)
n <- 1000
data <- data.frame(Treat = sample(1:3, n, replace=T),
                   Mort = runif(n,10,70))

data$Treat <- factor(data$Treat, 
              labels = c("Parthenogenetic", "Monoandrous", "Polyandrous"))

library(beanplot)
beanplot(Mort~Treat, data=data, col=list("firebrick", "deepskyblue3", "chartreuse4"),
          ylab="Number of days", xlab="Reproductive mode",
          las=1, ylim=c(0,80), cutmin = -Inf, cutmax = Inf, log="")

enter image description here

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58