2017-03-26 6 views
0

내 CSV : 내 x-axis 그렇게 보이는 이유R ggplot2 막대 그래프의 축으로

library(dplyr) 
ex <- read.csv("ex.csv", header = T) 
exgroup <- group_by(ex, year, com) 
sumex <- summarise(exgroup, sum(value1)) 
sumex 
    year com `sum(value1)` 
    <int> <fctr>   <int> 
1 2015  CH  387692 
2 2015  ZU  4601040 
3 2016  CH   49754 

ggplot(sumex,aes(x=year,y=`sum(value1)`,fill=com))+geom_bar(stat="identity", position=position_dodge()) 

MY ggplot

그러나, 나도 몰라 : 다음은

pro,year,month,com,value1,value2 
A,2015,1,CH,0,0 
A,2015,2,CH,3000,0 
A,2015,3,CH,234325,0 
A,2015,4,CH,16324,0 
A,2015,5,CH,53236,0 
A,2015,6,CH,4543,0 
A,2015,7,CH,0,0 
A,2015,8,CH,43576,29765 
A,2015,9,CH,7856,27845 
A,2015,10,CH,8976,5674 
A,2015,11,CH,6906,34562 
A,2015,12,CH,8950,23446 
A,2016,1,CH,6970,0 
A,2016,2,CH,6000,6906 
A,2016,3,CH,0,4875 
A,2016,4,CH,0,0 
A,2016,5,CH,0,0 
A,2016,6,CH,0,67843 
A,2016,7,CH,0,8980 
A,2016,8,CH,0,890 
A,2016,9,CH,0,7890 
A,2016,10,CH,0,3579 
A,2016,11,CH,36784,6090 
A,2016,12,CH,0,6782 
A,2015,1,ZU,0,0 
A,2015,2,ZU,0,0 
A,2015,3,ZU,0,0 
A,2015,4,ZU,0,0 
A,2015,5,ZU,0,0 
A,2015,6,ZU,0,0 
A,2015,7,ZU,0,0 
A,2015,8,ZU,4567890,8659 
A,2015,9,ZU,24640,8906 
A,2015,10,ZU,860,4876 
A,2015,11,ZU,0,4762 
A,2015,12,ZU,7650,5259 

내 코드? X 축을 및 으로 표시하도록 설정할 수 있습니까?
y-axis은 지수를 표시합니다. 숫자를 표시하도록 변경할 수 있습니까?

또한 %을 플롯에 표시하는 방법은 무엇입니까?

매우 감사합니다.

+1

귀하의 "해"값은 숫자가 아닌 요소이다. 'sumex $ year <- as.factor (sumex $ year)'를 실행하고 플롯을 다시 시도하십시오 – caw5cv

+0

감사합니다. 알았어. –

답변

1

y 축에 대한 두 번째 질문에 대한 답은 지수 기호입니다.

ggplot(sumex,aes(x=year,y=`sum(value1)`,fill=com)) 
+ geom_bar(stat="identity", position=position_dodge()) 
+ scale_y_continuous(labels = comma) 

scale_y_continuous을 추가하면 원하는 내용이 표시됩니다.

확인 참조 링크 :
R markdown html document not properly show in Internet Explorer