Many times I walk into this:
I already have a large ff object(represented by a matrix/array) and then I want to add a new column/row to it, as I have some updated data and don't want to create a new big object from scratch (which can be very time consuming).
I'm trying something like that:
t <- cbind(a = c(1,2,3,4,5), b=c(6,7,8,9,10))
ff.t <- ff(t, dim=dim(t))
# Adding new column works fine
dim(ff.t) <- c(5, 3)
ff (open) double length=15 (15) dim=c(5,3) dimorder=c(1,2)
[,1] [,2] [,3]
[1,] 1 6 0
[2,] 2 7 0
[3,] 3 8 0
[4,] 4 9 0
[5,] 5 10 0
# Adding new row gives error
dim(ff.t) <- c(6, 4)
dim(ff.t) <- c(6, 4) Error in
dim<-.ff
(*tmp*
, value = c(6, 4)) : you can only change the fastest rotating dim 1:dim<-
(*tmp*
, value = c(6, 4)) 2:dim<-.ff
(*tmp*
, value = c(6, 4)) 3: stop("you can only change the fastest rotating dim")
What does this mean ? Is there a way to workaround this and add columns/rows to an ff object (increasing also the filesize naturally) ? If you can't avoid creating a new object, what is the best way to do it ? The new column could be initialized with 0 or NA.
Thanks