私は動物園の時系列を持っていますmerged
:
merged <- structure(c("53736", "53736", "53737", "53737", "53738", "53738",
"2353.96", "2377.84", "2388.4", "2397.52", "2432.62", "2407.52",
"68.1", "71.4", "68.2", "75.3", "107.5", "80.3", "10.6", "11.1",
"10.6", "11.7", "16.8", "12.5", "2006-01-01 11:17:00", "2006-01-01 23:15:00",
"2006-01-02 11:17:00", "2006-01-02 23:15:00", "2006-01-03 11:16:00",
"2006-01-03 23:17:00", "11.206564", "13.019471", "11.784637",
"14.039267", "18.505121", "15.057849"), .Dim = c(6L, 6L), .Dimnames = list(
NULL, c("station_id", "ztd", "zwd", "iwv", "timestamp", "pwc"
)), index = structure(c(1136113200, 1136156400, 1136199600,
1136242800, 1136286000, 1136329200), class = c("POSIXct", "POSIXt"
)), class = "zoo")
構造を見ると、いくつかの列があることがわかります。
> str(merged)
‘zoo’ series from 2006-01-01 11:00:00 to 2010-03-24 23:00:00
Data: chr [1:2966, 1:6] "53736" "53736" "53737" "53737" "53738" "53738" "53739" ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:6] "station_id" "ztd" "zwd" "iwv" ...
Index: POSIXct[1:2966], format: "2006-01-01 11:00:00" "2006-01-01 23:00:00" "2006-01-02 11:00:00" ...
ただし、他のいくつかの列に数学演算子を使用して新しい列を作成しようとすると、機能しません。
> merged$error <- merged$pwc - merged$iwv
Error in `-.default`(merged$pwc, merged$iwv) :
non-numeric argument to binary operator
私は以前にこれを行ったことがあると確信しており、それはうまくいったので、私が間違っていることを理解することはできません。誰かアイデアはありますか?