es4dataframe | R Documentation |
this would be the typical way to instantiate an es4dataframe, an S4 wrapper for data.frame.
es4dataframe(..., stringsAsFactors = FALSE)
... |
all that good regular data.frame stuff |
stringsAsFactors |
boolean defaults to FALSE because why would you do anything else? |
a well behaving S4 data.frame
wrapper. i hope what you expect to happen happens. my main concern was that subsetting functions should return an S4 class instead of a data.frame
.
i've implemented methods for as.data.frame, $, [, [<
, and merge
. these methods are just simple wrappers for the S3 methods.
note that merge
will have to be implemented in any class that extends es4dataframe
and has slots so that these functions know how to merge those slots.
with the defaults and those definitions many methods work without fuss and return the S4 object including subset, na.omit, unique, $<-
.
other methods you don't expect to return the S4 class anyway work fine like: duplicated, as.list, [[
, etc.
i think it makes sense to let some methods default to returning the underlying data.frame
only and not the S4 class. for example, edit
. in the applications i have in mind, i don't really want the user to be able to edit the S4 classes data 'by hand'. and if you want that functionality you can always extend the class and add it.
i haven't implemented cbind
or rbind
because i can't figure out how to do it. they'd also have to be implemented in any class that extends es4dataframe
with slots.
an S4 class of es4dataframe
.
es4dataframe-class
as.data.frame-es4dataframe-method
testdf <- es4dataframe(a = rnorm(10), b = rnorm(10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.