Color error in ggplot2 (Error in grDevices::col2rgb(colour, TRUE) : invalid RGB specification)

13,136

Sorry I am late, but the problem is that the function alpha is masked form ggplot2, that's why if you restart R and happen to call alpha after sourcing psych but before ggplot2 it works.

Anyway, the way to solve it is to make explicit that we want the psych function:

reliability = psych::alpha(df)
Share:
13,136

Related videos on Youtube

Jacob Socolar
Author by

Jacob Socolar

A field ecologist who has to do something with the data he collects... I code with R, JAGS, and Matlab, and I am beginning to work with Stan.

Updated on September 15, 2022

Comments

  • Jacob Socolar
    Jacob Socolar over 1 year

    If I run:

    library(ggplot2)
    ToothGrowth$dose <- as.factor(ToothGrowth$dose)
    bp<-ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
        geom_boxplot()
    bp
    

    I see the error: Error in grDevices::col2rgb(colour, TRUE) : invalid RGB specification.

    If I run the identical code on my other computer, I get the expected plot. I am guessing that some plotting parameter is the culprit, but I have no idea how to find it. What's going wrong?

    The computer that behaves strangely is Mac OS X 10_11_3 running R 3.2.2 via RStudio 0.99.489

    • Richard Telford
      Richard Telford almost 8 years
      Can only recommend updating to the latest version of R.