Having trouble getting melt and dcast to work with ffdf
I'm trying to cast 3 columns to a square matrix
With a regular data.frame.....
comb <- expand.grid((1:10),(1:10))
dim(comb)
comb$Dist <- (1:100)
c.melt <- melt(comb, id.vars=c("Var1","Var2"))
dcast(c.melt,Var2~Var1)
goes from> comb
Var1 Var2 Dist
1 1 1 1
2 2 1 2
3 3 1 3
4 4 1 4
5 5 1 5
6 6 1 6
.....
to
> c.melt
Var1 Var2 variable value
1 1 1 Dist 1
2 2 1 Dist 2
3 3 1 Dist 3
4 4 1 Dist 4
5 5 1 Dist 5
6 6 1 Dist 6
.....
to> dcast(c.melt,Var1~Var2)
Var1 1 2 3 4 5 6 7 8 9 10
1 1 1 11 21 31 41 51 61 71 81 91
2 2 2 12 22 32 42 52 62 72 82 92
3 3 3 13 23 33 43 53 63 73 83 93
4 4 4 14 24 34 44 54 64 74 84 94
5 5 5 15 25 35 45 55 65 75 85 95
6 6 6 16 26 36 46 56 66 76 86 96
7 7 7 17 27 37 47 57 67 77 87 97
8 8 8 18 28 38 48 58 68 78 88 98
9 9 9 19 29 39 49 59 69 79 89 99
10 10 10 20 30 40 50 60 70 80 90 100
no trouble.
With ffdf it breaks on the melt step
comb.ff <- expand.ffgrid(ff(1:10),ff(1:10))
dim(comb.ff)
comb.ff$Dist <- ff(1:100)
> comb.ff
ffdf (all open) dim=c(100,3), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
PhysicalName VirtualVmode PhysicalVmode AsIs VirtualIsMatrix
PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
PhysicalIsOpen
Var1 Var1 integer integer FALSE
FALSE FALSE 1 1
1 TRUE
Var2 Var2 integer integer FALSE
FALSE FALSE 2 1
1 TRUE
Dist Dist integer integer FALSE
FALSE FALSE 3 1
1 TRUE
ffdf data
Var1 Var2 Dist
1 1 1 1
2 2 1 2
3 3 1 3
4 4 1 4
5 5 1 5
6 6 1 6
....
c.melt.ff <- melt(comb.ff,
id.vars=c("Var1","Var2"))> c.melt.ff
value NA NA
1 1 1 1
2 2 1 2
3 3 1 3
4 4 1 4
5 5 1 5
6 6 1 6
7 7 1 7
.....
Is it possible to use this method with ffdf?
I appreciate any help
Ken