Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/as.data.table.ffdf.R
Converts a Flat File Data Frame (ffdf) to a data.table object, or the other way around. FFDF is a convenient form for storing very large datasets without using RAM, but data.table is faster and convenient for data processing.
Also converts cohort objects from data.table cohorts to ffdf cohorts and vice versa.
1 2 3 4 5 6 7 8 9 10 | ## S3 method for class 'ffdf'
as.data.table(x, keep.rownames = FALSE, ...)
## S3 method for class 'cohort'
as.data.table(x, keep.rownames = FALSE, ...)
## S3 method for class 'data.table'
as.ffdf(x, vmode = NULL,
col_args = list(), ...)
## S3 method for class 'cohort'
as.ffdf(x, vmode = NULL,
col_args = list(), ...)
|
x |
object to convert (FFDF data frame, data.table or cohort). FFDF objects must have more than one row in order to be converted to data.table. |
keep.rownames |
TRUE will retain the rownames of x in a column named rn. |
vmode |
optional specification of the vmodes of columns of the data.frame. Either a character vector of vmodes (named with column names of the data.frame or recycled if not named) or a list named with vmodes where each element identifies those columns of the data.frame that should get the vmode encoded in the name of the element |
col_args |
further arguments; passed to ff |
... |
further arguments: passed to ffdf for .ff_vector, .ff_matrix and .data.frame methods; passed to as.data.table for as.data.table methods; ignored for .ffdf identity method |
If these functions are provided in the ffdf or data.table packages,
they will be removed from this package. as.ffdf.data.table
is a convenience function which automatically converts characters to
factors in the original data.table then calls as.ffdf.data.frame
.
as.ffdf
returns a FFDF object; as.data.table
returns a data.table object.
If the original object is a cohort, the output is also a cohort.
Anoop Shah
1 2 3 4 5 6 7 8 9 10 | mydatatable <- data.table(a = 1:6, b = 'this')
mydatatable
# Convert to ffdf (column b will be converted to a factor)
myffdf <- as.ffdf(mydatatable)
myffdf
# Convert back to data.table (column b remains as a factor)
as.data.table(myffdf)
str(mydatatable)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.