Date <- as.character(seq(from = as.Date("2001/1/1"),
to = as.Date("2002/1/2"),
by = "day"))
Q <- c(-1:365)
Qualifier <- rep("",367)
dataInput_complete <- data.frame(Date, Q, Qualifier)
dataInput <- dataInput_complete[-4:-5,]
# No fill, but with 0 and negative:
Daily <- populateDaily(dataInput, qConvert = 1)
# No negatives/zeros:
Q <- 2+sin(seq(from = 0, to = 2*pi, length.out = 367))
Q <- jitter(Q, factor = 500)
plot(Q, ylim = c(0, 3.2))
dataInput_complete <- data.frame(Date, Q, Qualifier)
# Remove some rows to test missing:
dataInput <- dataInput_complete[-4:-5,]
dataInput <- dataInput[-10:-20,]
# No fill:
Daily <- populateDaily(dataInput, qConvert = 1)
plot(Daily$Date[1:30], Daily$Q[1:30], type = "b", ylim = c(0, 3.2))
# Linear interpolation:
Daily_fill <- populateDaily(dataInput,
qConvert = 1,
fill = TRUE,
fill_type = "interpolation")
plot(Daily_fill$Date[1:30],
Daily_fill$Q[1:30],
col = as.factor(Daily_fill$Qualifier[1:30]),
type = "b", pch = 16, ylim = c(0, 3.2),
main = "Linear Interpolation")
# Add a gap that is too big do deal with:
dataInput <- dataInput_complete[-4:-20,]
dataInput <- dataInput[-200:-255,]
Daily_interp <- populateDaily(dataInput,
qConvert = 1,
fill = TRUE,
fill_type = "interpolation")
plot(Daily_interp$Date, Daily_interp$Q,
col = as.factor(Daily_interp$Qualifier),
main = "Linear Interpolation",
type = "b", pch = 16, ylim = c(0, 3.2))
plot(Daily_interp$Date[1:50], Daily_interp$Q[1:50],
col = as.factor(Daily_interp$Qualifier[1:50]),
main = "Linear Interpolation",
type = "b", pch = 16, ylim = c(0, 3.2))
Daily_log_interp <- populateDaily(dataInput,
qConvert = 1,
fill = TRUE,
fill_type = "log_interp")
plot(Daily_log_interp$Date, Daily_log_interp$Q,
col = as.factor(Daily_log_interp$Qualifier),
main = "Linear Interpolation in Log Scale",
type = "b", pch = 16, ylim = c(0, 3.2))
plot(Daily_log_interp$Date[1:50], Daily_log_interp$Q[1:50],
col = as.factor(Daily_log_interp$Qualifier[1:50]),
main = "Linear Interpolation in Log Scale",
type = "b", pch = 16, ylim = c(0, 3.2))
# Real data:
eList <- Choptank_eList
Daily_chop <- eList$Daily
df <- Daily_chop[,c("Date", "Q")]
df <- df[-2:-5, ]
df <- df[-100:-200,]
D2 <- populateDaily(df, 1, fill = TRUE)
plot(D2$Date[1:20], D2$Q[1:20],
col = as.factor(D2$Qualifier[1:20]),
main = "Linear Interpolation",
type = "b", pch = 16)
plot(D2$Date[1:110], D2$Q[1:110],
col = as.factor(D2$Qualifier[1:110]),
main = "Linear Interpolation",
type = "b", pch = 16)
Run the code above in your browser using DataLab