When using “geom_histogram” there is error “unit(tic_pos.c, ”mm“) : 'x' and 'units' must have length > 0”. Why

后端 未结 1 491
南旧
南旧 2020-12-25 09:43

When using geom_histogram there is error

unit(tic_pos.c, \"mm\") : \'x\' and \'units\' must have length > 0. 

Why?

相关标签:
1条回答
  • 2020-12-25 10:09

    You got this error because p values are numeric in your data frame but in this case for the fill= you need discrete values as bars are stacked and will be colored according to p. Just use as.factor() around p.

    ggplot(BCIcor,aes(x=cor,fill=as.factor(p)))+geom_histogram(binwidth = 0.2)
    
    0 讨论(0)
提交回复
热议问题