我有这个虚拟数据:
> dput(mergedDf)
structure(list(particles = c(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5,
1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5,
10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 50, 50, 50), timestamp = c(1477554578237,
1477554580104, 1477554580405, 1477554580621, 1477554580829, 1477554581048,
1477554581264, 1477128810777, 1477128812460, 1477128812666, 1477128812836,
1477128813036, 1477128813217, 1477128813386, 1477128813568, 1477128813769,
1477128813957, 1477128814128, 1477128814330, 1477128814513, 1477128814689,
1477128814881, 1477128815063, 1477128815425, 1477128815639, 1477128815853,
1477128816089, 1477128816299, 1477128816497, 1477554458704, 1477554461195,
1477554461478, 1477554461700, 1477554461925, 1477554462142, 1477554462365,
1477554462561, 1477554462795, 1477554463015, 1477554469995, 1477554470234,
1477554470441, 1477554470658, 1477554470869, 1477554471066, 1477554471287,
1477554471531, 1477554471827, 1477563960753, 1477564132825, 1477638346229,
1477638489644, 1477638506435, 1477128819834, 1477128821680, 1477128821901,
1477128822101, 1477128822277, 1477128822452, 1477128822637, 1477128822833,
1477128823013, 1477128823177, 1477128823534, 1477128823726, 1477128823926,
1477128824165, 1477128824350, 1477128824720, 1477128824910, 1477128825092,
1477128825293, 1477128798198, 1477128804065, 1477128804277, 1477128804477,
1477128804657, 1477128804849, 1477128805007, 1477128805375, 1477128805575,
1477128805775, 1477128805992, 1477128806232, 1477554117958, 1477554123118,
1477554429609, 1477554557560, 1477554559596, 1477554559858, 1477554560138,
1477554560370, 1477554560618, 1477554560884, 1477636388874, 1477554450626,
1477554452687, 1477554452916, 1477554453174, 1477554453376, 1477554486384,
1477554488340, 1477554488568, 1477554488797, 1477554489216, 1477554489490,
1477554489769, 1477554504746, 1477554504992, 1477554505214, 1477554505439,
1477554505679, 1477554505901, 1477554610058, 1477554611656, 1477554611915,
1477128829412, 1477128831017, 1477128831262, 1477128831504, 1477128831688,
1477128831880, 1477128832041, 1477128832242, 1477128832400, 1477128832600,
1477128832769, 1477128832928, 1477128833107, 1477128833278, 1477128833471,
1477128833632, 1477128833808, 1477129018233, 1477129018435, 1477129018649,
1477129018833, 1477129019029, 1477129019219, 1477129019411, 1477129019596,
1477129019787, 1477129019981, 1477129020198, 1477554474735, 1477554476443,
1477554476641, 1477554477049, 1477554477291, 1477554477498, 1477554477694,
1477554477891, 1477554478123, 1477129029789, 1477129032262, 1477129032486,
1477129032688, 1477129032884, 1477129033085, 1477129033278, 1477129033458,
1477129033647, 1477129033831, 1477129034028, 1477129034206, 1477129034408,
1477129034610, 1477129034824, 1477554549825, 1477554551833, 1477554552088,
1477554552493, 1477554552703, 1477554552913, 1477554553111, 1477554553330,
1477554553592, 1477554553857, 1477554554107, 1477554601052, 1477554602988,
1477554603250), date = structure(c(1477554578.237, 1477554580.104,
1477554580.405, 1477554580.621, 1477554580.829, 1477554581.048,
1477554581.264, 1477128810.777, 1477128812.46, 1477128812.666,
1477128812.836, 1477128813.036, 1477128813.217, 1477128813.386,
1477128813.568, 1477128813.769, 1477128813.957, 1477128814.128,
1477128814.33, 1477128814.513, 1477128814.689, 1477128814.881,
1477128815.063, 1477128815.425, 1477128815.639, 1477128815.853,
1477128816.089, 1477128816.299, 1477128816.497, 1477554458.704,
1477554461.195, 1477554461.478, 1477554461.7, 1477554461.925,
1477554462.142, 1477554462.365, 1477554462.561, 1477554462.795,
1477554463.015, 1477554469.995, 1477554470.234, 1477554470.441,
1477554470.658, 1477554470.869, 1477554471.066, 1477554471.287,
1477554471.531, 1477554471.827, 1477563960.753, 1477564132.825,
1477638346.229, 1477638489.644, 1477638506.435, 1477128819.834,
1477128821.68, 1477128821.901, 1477128822.101, 1477128822.277,
1477128822.452, 1477128822.637, 1477128822.833, 1477128823.013,
1477128823.177, 1477128823.534, 1477128823.726, 1477128823.926,
1477128824.165, 1477128824.35, 1477128824.72, 1477128824.91,
1477128825.092, 1477128825.293, 1477128798.198, 1477128804.065,
1477128804.277, 1477128804.477, 1477128804.657, 1477128804.849,
1477128805.007, 1477128805.375, 1477128805.575, 1477128805.775,
1477128805.992, 1477128806.232, 1477554117.958, 1477554123.118,
1477554429.609, 1477554557.56, 1477554559.596, 1477554559.858,
1477554560.138, 1477554560.37, 1477554560.618, 1477554560.884,
1477636388.874, 1477554450.626, 1477554452.687, 1477554452.916,
1477554453.174, 1477554453.376, 1477554486.384, 1477554488.34,
1477554488.568, 1477554488.797, 1477554489.216, 1477554489.49,
1477554489.769, 1477554504.746, 1477554504.992, 1477554505.214,
1477554505.439, 1477554505.679, 1477554505.901, 1477554610.058,
1477554611.656, 1477554611.915, 1477128829.412, 1477128831.017,
1477128831.262, 1477128831.504, 1477128831.688, 1477128831.88,
1477128832.041, 1477128832.242, 1477128832.4, 1477128832.6, 1477128832.769,
1477128832.928, 1477128833.107, 1477128833.278, 1477128833.471,
1477128833.632, 1477128833.808, 1477129018.233, 1477129018.435,
1477129018.649, 1477129018.833, 1477129019.029, 1477129019.219,
1477129019.411, 1477129019.596, 1477129019.787, 1477129019.981,
1477129020.198, 1477554474.735, 1477554476.443, 1477554476.641,
1477554477.049, 1477554477.291, 1477554477.498, 1477554477.694,
1477554477.891, 1477554478.123, 1477129029.789, 1477129032.262,
1477129032.486, 1477129032.688, 1477129032.884, 1477129033.085,
1477129033.278, 1477129033.458, 1477129033.647, 1477129033.831,
1477129034.028, 1477129034.206, 1477129034.408, 1477129034.61,
1477129034.824, 1477554549.825, 1477554551.833, 1477554552.088,
1477554552.493, 1477554552.703, 1477554552.913, 1477554553.111,
1477554553.33, 1477554553.592, 1477554553.857, 1477554554.107,
1477554601.052, 1477554602.988, 1477554603.25), class = c("POSIXct",
"POSIXt"), tzone = "UTC-1"), site = c("16", "16", "16", "16",
"16", "16", "16", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16"), code = c("16", "16", "16", "16", "16", "16", "16",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "16", "16", "16", "16", "16", "16",
"16", "16", "16", "17", "17", "17", "17", "17", "17", "17", "17",
"17", "17", "17", "17", "17", "17", "17", "16", "16", "16", "16",
"16", "16", "16", "16", "16", "16", "16", "16", "16", "16"),
key_date = c("2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-28", "2016-10-28", "2016-10-28", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-28", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22",
"2016-10-22", "2016-10-22", "2016-10-22", "2016-10-22", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27", "2016-10-27",
"2016-10-27", "2016-10-27", "2016-10-27")), .Names = c("particles",
"timestamp", "date", "site", "code", "key_date"), row.names = c(NA,
-182L), class = "data.frame")
我想用openair绘制这些数据:
## first drop site name
thedata <- subset(mergedDf, select = -site)
# Load package.
library(reshape2)
## now reshape the data using the reshape package
thedata <- melt(thedata, id.vars = c("date", "code"))
thedata <- dcast(thedata, ... ~ code + variable)
# Empty vector for storing line_pollutants later.
line_pollutants <- c()
selectedStream1Title <- '17'
selectedSpecies <- 'particles'
# Concat the string.
stream1PollutantCode <- paste(selectedStream1Title, "_", selectedSpecies, sep = "")
# Append the data to the list.
line_pollutants <- append(line_pollutants, stream1PollutantCode)
selectedStream2Title <- '16'
selectedSpecies <- 'particles'
# Concat the string.
stream2PollutantCode <- paste(selectedStream2Title, "_", selectedSpecies, sep = "")
# Append the data to the list.
line_pollutants <- append(line_pollutants, stream2PollutantCode)
# Load openair for plotting the data.
library("openair")
功能:
timePlot(
thedata,
pollutant = line_pollutants,
avg.time = "1 min", << this causes the error...
group = TRUE,
lwd = 2
)
错误:
Error in seq.default(h[1], h[2], length = n) :
'to' cannot be NA, NaN or infinite
这是什么意思?
但avg.time = "default"
:
timePlot(
thedata,
pollutant = line_pollutants,
avg.time = "default",
group = TRUE,
lwd = 2
)
为什么avg.time = "1 min"
导致上述错误?我的数据或别的东西有问题吗?
有什么想法吗?