4
當我執行下面的我的「預測」數據集是正確填充:R hdf5數據集寫入不正確?
library(rhdf5)
library(forecast)
library(sltl)
library(tseries)
fid <- H5Fcreate(output_file)
## TODO: compute the order p
p <- 4
# write predictors
h5createDataset(output_file, dataset="predictors", c(p, length(tsstl.remainder) - (p - 1)), storage.mode='double')
predictors <- as.matrix(tsstl.remainder)
for (i in 1:(p - 1)) {
predictors <- as.matrix(cbind(predictors, Lag(as.matrix(tsstl.remainder), i)))
}
predictors <- as.matrix(predictors[-1:-(p-1),])
head(predictors)
h5write(predictors, output_file, name="predictors")
H5Fclose(fid)
生成的(正確)的輸出head(predictors)
是:
[,1] [,2] [,3] [,4]
[1,] 0.3089645 6.7722063 5.1895389 5.2323261
[2,] 8.7607228 0.3089645 6.7722063 5.1895389
[3,] -0.9411553 8.7607228 0.3089645 6.7722063
[4,] -14.1390243 -0.9411553 8.7607228 0.3089645
[5,] -26.6605296 -14.1390243 -0.9411553 8.7607228
[6,] -8.1293076 -26.6605296 -14.1390243 -0.9411553
然而,當我看到它的結果是不糾正:
tsmatrix <- t(as.matrix(h5read(output_file, "predictors")))
head(tsmatrix)
錯誤輸出:
[,1] [,2] [,3] [,4]
[1,] 0.3089645 8.760723 -0.9411553 -14.13902
[2,] -26.6605296 -8.129308 -9.8687675 31.52086
[3,] 54.2703126 43.902489 31.8164836 43.87957
[4,] 22.1260636 36.733055 54.7064107 56.35158
[5,] 36.3919851 25.193068 48.2244464 57.12196
[6,] 48.0585673 72.402673 68.3265518 80.18960
爲什麼我寫的東西與我回來的東西不符?我再次檢查並且hdfview HDF5查看器也爲「預測者」數據集顯示了這個不正確的值。
這裏有什麼問題?
請提及您正在使用的任何和所有軟件包 – Dason
嘗試使用't'嗎? – blmoore
圖書館提供,與t是完全相同的輸出,我在hdfview中是非常奇怪的。 –