2014-04-01 4 views
1

아래 데이터와 코드를 사용하여 g.3plot2에서 ggplot2를 사용하여 선 그래프를 그려보고자하지만 출력없이 geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?의 오류를 반환합니다. 나는이 문제를 해결하려면 어떻게 내가 축에 문자를 사용하여, 일반적으로ggplot2에 선 그래프 그리기

month <- c("01", "02", "03", "04", "05", "06", "07", "08" ,"09","10", "11" ,"12",NA) 
yr.count <- c(357.500000 ,301.785714, 317.142857 ,283.071429 ,332.500000 ,333.285714 ,354.285714, 308.357143 ,272.142857 ,273.214286, 312.571429 ,337.714286,5.92857) 
month.mean2 <- data.frame(month=month, yr.count=yr.count) 
ggplot() + geom_line(data=month.mean2, 
        aes(x=month, y=as.numeric(yr.count)), 
        colour='red') 

답변

1

this 시도는 각각의 고유 값에 대한 여러 값이 있다는 것을 의미하고, 통합의 어떤 자리를 차지할 필요가있다. 당신은 group = 1을 설정하여 연결하는 선을 강제 할 수

month <- c("01", "02", "03", "04", "05", "06", "07", "08" ,"09","10", "11" ,"12",NA) 
yr.count <- c(357.500000 ,301.785714, 317.142857 ,283.071429 ,332.500000 ,333.285714 ,354.285714, 308.357143 ,272.142857 ,273.214286, 312.571429 ,337.714286,5.92857) 
month.mean2 <- data.frame(month=month, yr.count=yr.count) 
ggplot() + geom_line(data=month.mean2, 
        aes(x=month, y=as.numeric(yr.count), group = 1), 
        colour='red') 

enter image description here