我正在尝试将ff向量与POSIXct条目转换为ff数值向量,其中包含自原点01-01-1970年以来的相应秒数。
x = as.ff(as.POSIXct(c("2014-06-30 00:01:27 BST", "2014-06-30 00:02:17 BST")))
“自然”as.numeric(x)不起作用,结果是:numeric(0)。
as.ff(as.numeric(x[]))工作,产量
ff (open) double length=2 (2) [1] [2] 1398898887 1398898937
这是理想的结果。尽管如此,它涉及到ram对象x[]。是否有方法仅使用ff对象(即不中介ff向量的ram等价)来实现上述结果?
发布于 2014-06-30 12:13:39
require(ff)
x = as.ff(as.POSIXct(c("2014-06-30 00:01:27 BST", "2014-06-30 00:02:17 BST")))
## Either clone it (creates a duplicate of the ff file)
done <- clone(x, ramclass = "numeric", ramattribs = list())
done[]
[1] 1404079287 1404079337
attr(,"class")
[1] "numeric"
## Or just modify the ramclass and ramattribs (see ?virtual: virtual(x))
virtual(x)$ramclass <- NULL
virtual(x)$ramattribs <- NULL
x[]
[1] 1404079287 1404079337
## And wrap this up in your own functionhttps://stackoverflow.com/questions/24489004
复制相似问题