'Subset Data by Date when using FF / FFBase2
I'm using the ff/ffbase2 package to handle a large dataset. The dataset is read in; and I would like to create a subset based on the specified date in the "DATE" column. Note that the dates in the DATE column are saved in the formatt mm/dd/yyyy.
Without using ff, this looks as following (having specified the DATE column with as.Date before):
df <- df %>%
filter(df$date>'2014-12-31' & df$date < '2019-01-01')
From the ffbase2-package, I'd like to use the subset.ffdf function to achieve this with an ffdf-table. The data has already been read in using the read.table.ffdf function. Unlike the previous case where a simple dataframe is used, this command here
df$date <- as.Date(df$date, format = "%m/%d/%Y")
no longer works (gives an error message). Hence, as a consequence, the subsetting desired by the subset.ffdf function does not detect my DATE column as a date and does not function properly.
When using another 'filtering'-variable, the function works as below:
df_subset <- subset.ffdf(df, c2 == 4,
select = c(c3, c4, c5)
)
Could anyone please tell me how I can achieve what was done in the first code excerpt, but in an ffdf environment with the subset.ffdf function? It most probably has to do with me being unable to specify the DATE column as having stored dates, that is, changing the column class.
Please note that I have extensively browsed through previously asked questions in this domain, and nothing has helped thus far.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
