또는 기본 R과 ggplot2 솔루션 :
# date object
d$month2 <- as.Date(as.character(d$month), "%Y-%d-%m")
> str(d)
'data.frame': 5 obs. of 3 variables:
$ count : int 3 4 3 12 12
$ month : Factor w/ 5 levels "2014-10-01","2014-13-02",..: 1 4 2 3 5
$ month2: Date, format: "2014-01-10" "2014-01-15" "2014-02-13" "2014-02-14" ...
# per month
res <- aggregate(d$count, list(months(d$month2)), sum)
# again a date object
res$month <- as.Date(paste0("01-", res$Group.1, "-2014"), "%d-%B-%Y")
# plot
ggplot(res, aes(x= month, y=x)) +
geom_point() + geom_line() +
scale_x_date(date_minor_breaks = "1 month",date_labels = "%B")
당신은 또한 모두, 바 플롯 당 포인트 카운트와 같은 원시 데이터를 포함하도록 시도 할 수 있습니다 :
ggplot(d, aes(x= month2, y=count)) +
geom_point(col="red") +
scale_x_date(date_minor_breaks = "1 month",date_labels = "%B") +
geom_bar(data = res, aes(x= month, y=x),stat = "identity", position = 'identity',width=0.5)
당신은 [yearmon 객체]로 (HTTPS를 날짜를 변환 시도 할 수 있습니다 : // www.rdocumentation.org/packages/zoo/versions/1.7-14/topics/yearmon).이 요소는 요인과 유사하게 행동하기 때문에 쉽게 그룹화 할 수 있습니다. – cylim