R: “Unary operator error” from multiline ggplot2 command

前端 未结 4 1065
半阙折子戏
半阙折子戏 2020-12-29 02:31

I\'m using ggplot2 to do a boxplot comparison of two different species, as indicated by the third column shown below:

> library(reshape2)
> library(ggp         


        
4条回答
  •  北海茫月
    2020-12-29 02:44

    It's the '+' operator at the beginning of the line that trips things up (not just that you are using two '+' operators consecutively). The '+' operator can be used at the end of lines, but not at the beginning.

    This works:

    ggplot(combined.data, aes(x = region, y = expression, fill = species)) +
    geom_boxplot() 
    

    The does not:

    ggplot(combined.data, aes(x = region, y = expression, fill = species))
    + geom_boxplot() 
    
    *Error in + geom_boxplot():
    invalid argument to unary operator*
    

    You also can't use two '+' operators, which in this case you've done. But to fix this, you'll have to selectively remove those at the beginning of lines.

提交回复
热议问题