Help needed: non-numeric argument to binary operator

Did you paste the code exactly as you are running it? Because when I try to run the code (mocking up your data frame as best I could), I'm getting a different error due to the syntactically invalid name:

# Create some fake data with a similar format as the real data
Figure1 <- data.frame(
  Species = c(rep("Species1", 5), rep("Species2", 5)),
  `opt-out rate` = rbinom(10, 10, 0.5)/10,
  `Chosen-forced advantage` = c(rep(0.002, 5), rep(NA, 5)),
  check.names = FALSE
)

boxplot(split(Figure1$opt-out rate,Figure1$Species))
#> Error: <text>:9:31: unexpected symbol
#> 8: 
#> 9: boxplot(split(Figure1$opt-out rate
#>                                  ^

Created on 2018-07-21 by the reprex package (v0.2.0).

Have you taken a look at this community's recommendations for asking questions about R code? The example above shows a couple of strongly recommended practices: including sample data (screenshots can't be easily run!) and using the reprex package to format examples, which shows both the code and the output.

1 Like