[R] ffbase, help with %in%
Jan van der Laan
rhelp at eoos.dds.nl
Tue Oct 2 15:18:11 CEST 2012
It doesn't seem possible to index an ff-vector using a logical
ff-vector. You can use subset (also in ffbase) or first convert 'a' to
a normal logical vector:
library(ff)
library(ffbase)
data1 <- as.ffdf(data.frame(a = letters[1:10], b=1:10))
data2 <- as.ffdf(data.frame(a = letters[5:26], b=5:26))
a <- data1[[1]] %in% data2$a
subset(data1, a)
data1[a[], ]
HTH,
Jan
Lucas Chaparro <lpchaparrovio at gmail.com> schreef:
> Hello to everyone.
> I'm trying to use the %in% to match to vectors in ff format.
> a<-as.ff(data[,1]) %in% fire$fecha
>
>> aff (open) logical length=3653 (3653)
> [1] [2] [3] [4] [5] [6] [7] [8] [3646]
> FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE : FALSE
> [3647] [3648] [3649] [3650] [3651] [3652] [3653]
> FALSE FALSE FALSE FALSE FALSE FALSE FALSE
>
>
> Here you see a part of the data:
>
> data[1:20,] (just a sample, data has 3653 obs)
>
> fecha juliano altura UTM.E UTM.N
> 1 1990-07-01 182 15 248500 6239500
> 2 1990-07-02 183 15 248500 6239500
> 3 1990-07-03 184 15 248500 6239500
> 4 1990-07-04 185 15 248500 6239500
> 5 1990-07-05 186 15 248500 6239500
> 6 1990-07-06 187 15 248500 6239500
> 7 1990-07-07 188 15 248500 6239500
> 8 1990-07-08 189 15 248500 6239500
> 9 1990-07-09 190 15 248500 6239500
> 10 1990-07-10 191 15 248500 6239500
> 11 1990-07-11 192 15 248500 6239500
> 12 1990-07-12 193 15 248500 6239500
> 13 1990-07-13 194 15 248500 6239500
> 14 1990-07-14 195 15 248500 6239500
> 15 1990-07-15 196 15 248500 6239500
> 16 1990-07-16 197 15 248500 6239500
> 17 1990-07-17 198 15 248500 6239500
> 18 1990-07-18 199 15 248500 6239500
> 19 1990-07-19 200 15 248500 6239500
> 20 1990-07-20 201 15 248500 6239500
>
>
>> fire$fecha[1:20,] [1] "1984-11-08" "1984-11-08" "1984-11-09"
>> "1984-11-09" "1984-11-09"
> [6] "1984-11-10" "1984-11-10" "1984-11-11" "1984-11-11" "1984-11-11"
> [11] "1984-11-11" "1984-11-11" "1984-11-11" "1984-11-12" "1984-11-12"
> [16] "1984-11-13" "1984-11-13" "1984-11-13" "1984-11-14" "1984-11-14"
>
>
> to see if a got any match:
>
>
> table.ff(a)
>
>
> FALSE TRUE
> 1687 1966 Mensajes de aviso perdidosIn if (useNA == "no") c(NA, NaN) :
> la condición tiene longitud > 1 y sólo el primer elemento será usado
>
>
> in a regular data.frame I use data[a,] to extract the rows that a ==
> TRUE, but when i do this in a ffdf i get this error:
>
>
>> data[a,]Error: vmode(index) == "integer" is not TRUE
>
>
> I'm just learning how to use the ff package so, obviously I'm
> missing something
>
>
> If any of you knows how to solve this, please teach me.
>
> Thank you so much.
>
>
> Lucas.
>
> [[alternative HTML version deleted]]
More information about the R-help
mailing list