[R] How to subset an 'ff' object?

David Winsemius dwinsemius at comcast.net
Sun Dec 29 05:40:33 CET 2013


On Dec 28, 2013, at 9:26 AM, Christofer Bogaso wrote:

> Hi again,
> 
> I have loaded a huge csv file in R using 'ff' package, however could not
> understand how can I subset the loaded object. Below is my try:
> 
>> suppressMessages(library(ff))
>> 
>> Dat <- read.csv.ffdf(file = "f:/Book1.csv", header = F, colClasses =
> c('Date', 'factor'))
>> Dat
> ffdf (all open) dim=c(4,2), dimorder=c(1,2) row.names=NULL
> ffdf virtual mapping
>   PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix
> PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
> PhysicalIsOpen
> V1           V1       double        double FALSE           FALSE
> FALSE                 1                1               1           TRUE
> V2           V2      integer       integer FALSE           FALSE
> FALSE                 2                1               1           TRUE
> ffdf data
>          V1         V2
> 1 2013-12-28 a
> 2 2013-12-28 b
> 3 2013-12-27 c
> 4 2013-12-27 c
>> 
>> subset(Dat, Dat$V1 == as.Date('2013-12-27'))
> ffdf (all open) dim=c(4,0), dimorder=c(1,2) row.names=NULL
> ffdf virtual mapping
> [1] PhysicalName      VirtualVmode      PhysicalVmode     AsIs
> VirtualIsMatrix   PhysicalIsMatrix  PhysicalElementNo PhysicalFirstCol
> PhysicalLastCol
> [10] PhysicalIsOpen
> <0 rows> (or 0-length row.names)
> ffdf data
> [1] "[empty matrix]"

> ?ff::subset
No documentation for ‘subset’ in specified packages and libraries:
you could try ‘??subset’

If there was there something in the documentation that suggested `subset` should succeed with an 'ffdf' object, then you should write to the package authors.

Perhaps you should read ?ff::Extract.ff

-- 
David.
> 
> 
> 
> My resulting object is showing '0' rows!
> 
> 
> The 'Dat' object looks like below:
> 
>> dput(Dat)
> structure(list(virtual = structure(list(VirtualVmode = c("double",
> "integer"), AsIs = c(FALSE, FALSE), VirtualIsMatrix = c(FALSE,
> FALSE), PhysicalIsMatrix = c(FALSE, FALSE), PhysicalElementNo = 1:2,
>    PhysicalFirstCol = c(1L, 1L), PhysicalLastCol = c(1L, 1L)), .Names =
> c("VirtualVmode",
> "AsIs", "VirtualIsMatrix", "PhysicalIsMatrix", "PhysicalElementNo",
> "PhysicalFirstCol", "PhysicalLastCol"), row.names = c("V1", "V2"
> ), class = "data.frame", Dim = c(4L, 2L), Dimorder = 1:2), physical =
> structure(list(
>    V1 = structure(list(), physical = <pointer: 0x0298f498>, virtual =
> structure(list(), Length = 4L, Symmetric = FALSE, ramclass = "Date"), class
> = c("ff_vector",
>    "ff")), V2 = structure(list(), physical = <pointer: 0x0298f4c8>,
> virtual = structure(list(), Length = 4L, Symmetric = FALSE, Levels = c("a",
>    "b", "c"), ramclass = "factor"), class = c("ff_vector", "ff"
>    ))), .Names = c("V1", "V2")), row.names = NULL), .Names = c("virtual",
> "physical", "row.names"), class = "ffdf")
> 
> 
> Can experts here guide me how to subset that?
> 
> Thanks for your time.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list