Description Usage Arguments Details Functions Examples
ConvertDailyToMonthly takes a daily table and convert it to a monthly table with values equal to the mean. Conversely, ConvertMonthlyToDaily takes a monthly table and convert it to a daily table.
1 2 3 | ConvertDailyToMonthly(df)
ConvertMonthlyToDaily(df, type = "step", indicator.df = NULL)
|
df |
A data frame to be converted. The first column needs to be a date column. |
type |
Smoothing type for monthly-to-daily conversion. c("step", "smooth", "smooth.naive). Default set at "step." |
indicator.df |
An optional input for denton disaggregation. It should be a data frame with "Date" as the first column, and the same number of columns as df, in a daily granularity. |
When 'step' is chosen for disaggregation method, data is simply extrapolated as constants through the months. For 'smooth' disaggregation, the default setting is by denton method. If naive smoothing is chosen, piece-wise deinfed 2nd degree polynomial method is used.
ConvertMonthlyToDaily
: Take a monthly data frame and convert it to daily data frame.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(reshape)
library(tea.eo.plots)
niter <- 2
monthly.df <- data.frame("Date"=rep(seq(as.Date("2010-1-1"), by="month", length.out = 12),niter)
, "Iter" = rep(1:niter,each=12), "Y"=rnorm(12*niter))
monthly.df <- cast(monthly.df, Date ~ Iter, value="Y")
plot0(monthly.df$Date, monthly.df$'1', ylim=c(-3,3))
matlines(monthly.df$Date, monthly.df[,-1], lwd=2, lty=1)
daily.df <- ConvertMonthlyToDaily(monthly.df)
matlines(daily.df$Date, daily.df[,-1], lty=2)
daily.df <- ConvertMonthlyToDaily(monthly.df, type="smooth")
matlines(daily.df$Date, daily.df[,-1])
daily.df <- ConvertMonthlyToDaily(monthly.df, type="smooth"
, indicator.df = data.frame("Date"=seq(as.Date("2010-1-1"), by="day", length.out = 400), rnorm(400, sd=0.5), rnorm(400, sd=0.5)))
matlines(daily.df$Date, daily.df[,-1])
verify.df <- ConvertDailyToMonthly(daily.df)
matlines(verify.df$Date, verify.df[,-1], lwd=10, lty=1, col=gray.f(0.3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.