ProgramingTip

“geom_histogram”을 사용할 때“unit (tic_pos.c,”mm“) : 'x'및 'units'의 길이가 0보다 커야합니다.

bestdevel 2020. 11. 18. 09:33
반응형

“geom_histogram”을 사용할 때“unit (tic_pos.c,”mm“) : 'x'및 'units'의 길이가 0보다 커야합니다.


사용시 geom_histogram오류가 있습니다.

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

왜?

p4<-ggplot(BCIcor,aes(x=cor))+geom_histogram(binwidth = 0.2)    

이것은 검은 색 막대 차트를 보여줍니다. 그러나 p거기에는 화려하게 만들기 위해 데이터를 그룹화하고 싶을 때 fill=p,

p4<-ggplot(BCIcor,aes(x=cor,fill=p))+geom_histogram(binwidth = 0.2)

나는 다음을두고 :

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

뭐가 문제 야 ??

데이터 프레임은 다음과 가변합니다.

  cor        pvalue   p 

1  0.87882370 0.049710 2       
2 -0.83041880 0.081660 1         
3 -0.12989750 0.835100 1        
4 -0.75309860 0.141700 1        
5 -0.88553450 0.045680 2

이 오류 p는 데이터 프레임에서 값이 숫자이기 때문에 발생 하지만이 경우 fill=막대가 쌓이고에 따라 색상이 지정되고 이산 값이 필요합니다 p. as.factor()주위에 사용하십시오 p.

ggplot(BCIcor,aes(x=cor,fill=as.factor(p)))+geom_histogram(binwidth = 0.2)

참고 URL : https://stackoverflow.com/questions/16569489/when-using-geom-histogram-there-is-error-unittic-pos-c-mm-x-and-uni

반응형