Is there a way to do simple arithmetic operations on ff class matrices? ie something like this:
> library(ff)
> a = ff(1, vmode = "double", dim = c(3,4))
> b = ff(2, vmode = "double", dim = c(3,4))
> a+b
Error in a + b : non-numeric argument to binary operator
I know ffbase can do this on vectors, but haven't found anything for matrices. Thanks.
Reading ?LimWarn I see a details section entitled "Multiple vector interpretation in arrays" whose penultimate sentence is:
To access the array elements in R standard dimorder you simply use [ which dispatches to [.ff_array.
a[]+b[]
[,1] [,2] [,3] [,4]
[1,] 3 3 3 3
[2,] 3 3 3 3
[3,] 3 3 3 3
(The results is an not an ff
-object.)
Or, as hinted at in ?ff
:
as.ram(a) +as.ram(b)
[,1] [,2] [,3] [,4]
[1,] 3 3 3 3
[2,] 3 3 3 3
[3,] 3 3 3 3
attr(,"physical")
(hidden, use physical(x) to access the physical attributes and vmode(x) for accessing vmode)
attr(,"virtual")
(hidden, use virtual(x) to access the virtual attributes)
attr(,"vmode")
[1] "double"
(The result is an ff
-object.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.