는 음모 개월로 분할 cycle
를 사용 autoplot.zoo
, 동물원에 데이터를 변환합니다. 아래에서는 네 가지 다른 방법을 보여줍니다. 먼저 우리는 1 월을 계획합니다. 그런 다음 매달 모든 달을 별도의 패널에 플롯 한 다음 매월 모든 달을 별도 패널로 모두 같은 패널에 표시합니다. 마지막으로 monthplot
(ggplot2 아님)을 사용하여 한 패널에 모두 다른 방식으로 그려줍니다.
zz <- zoo(matrix(coredata(z), 40, 12, byrow=TRUE), unique(as.numeric(trunc(time(z)))))
업데이트 : 추가 플롯 유형과 접근 방식을 개선
library(zoo)
library(ggplot2)
# test data
set.seed(123)
temp <- data.frame(date = as.yearmon(1980 + 0:479/12), value = rnorm(480))
z <- read.zoo(temp, FUN = identity) # convert to zoo
# split into 12 series and cbind them together so zz480 is 480 x 12
# Then aggregate to zz which is 40 x 12
zz480 <- do.call(cbind, split(z, cycle(z)))
zz <- aggregate(zz480, as.numeric(trunc(time(zz480))), na.omit)
### now we plot this 4 different ways
#####################################
# 1. plot just January
autoplot(zz[, 1]) + ggtitle("Jan")
# 2. plot each in separate panel
autoplot(zz)
# 3. plot them all in a single panel
autoplot(zz, facet = NULL)
# 4. plot them all in a single panel in a different way (not using ggplot2)
monthplot(z)
참고 zz
을 계산하는 다른 방법이 될 것이라고.
어떤 용도로 사용 되었습니까? – DatamineR
네, 모두 고맙습니다. 똑같은 일을하는 여러 가지 방법을 보여주기 위해서! 귀하의 도움을 주시면 감사하겠습니다! – nee