Hi all
I'm trying to make some assignments to an ffdf using values coming in as
3 columns (row, col, values)
As an example with a regular matrix assigning data (d) to row r and
column c from a data frame assigns the 3 specific values as desired
reg.mat <- matrix(0, nrow=5, ncol=5)> reg.mat
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
coldat <- data.frame(r = c(1,2,4), c = c(2,1,3), d=c(10,11,12))
> coldat
r c d
1 1 2 10
2 2 1 11
3 4 3 12
reg.mat[cbind(coldat$r, coldat$c)] <- coldat$d> reg.mat
[,1] [,2] [,3] [,4] [,5]
[1,] 0 10 0 0 0
[2,] 11 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 12 0 0
[5,] 0 0 0 0 0
However using an ff matrix with an incoming 3 column ffdf I cant seem to
get it to go...
ff.mat<-ff(as.integer(0), dim=c(5,5))
> tst.mat
ff (open) integer length=25 (25) dim=c(5,5) dimorder=c(1,2)
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
coldatff <-
ffdf(r=ff(as.integer(c(1,2,4))),c=ff(as.integer(c(2,1,3))),d=ff(as.integer(c(10,11,12))))
> coldatff
ffdf (all open) dim=c(3,3), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
PhysicalName VirtualVmode PhysicalVmode AsIs VirtualIsMatrix
PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
r r integer integer FALSE
FALSE FALSE 1 1 1
c c integer integer FALSE
FALSE FALSE 2 1 1
d d integer integer FALSE
FALSE FALSE 3 1 1
PhysicalIsOpen
r TRUE
c TRUE
d TRUE
ffdf data
r c d
1 1 2 10
2 2 1 11
3 4 3 12
ff.mat[cbind(coldatff$r,coldatff$c)] <-coldatff$d
> ff.mat
ff (open) integer length=25 (25) dim=c(5,5) dimorder=c(1,2)
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
Using cbind = still getting only zeros. Tried a few other methods I just
cant seem to wrap my head around how to do this.....
I had a look at ffindexset, but that looks like assigning whole rows at
a time.
I appreciate any help !!
Thanks
Ken