Description Usage Arguments Details Value Examples
The name 'dfat' comes from 'df' for data frames, and '
This overwrites the slotOP
http://www.inside-r.org/r-doc/base/slotOp, which is only for S4 objects.
1 | x %@@% key
|
x |
A list of lists, where the sub-lists should have named members. |
key |
Either a string that is the name of the attribute to extract, or an integer index of the attribute to extract. |
Imagine you have a data.frame where a variable/column is a list of lists, and the lists have named members, e.g.,
df$itinary <- list(
list(from="NYC", to="LA", price=1200, via="train"),
list(from="LA", to="SF", price="unknown"),
...)
You want to get the "from" value of itinary as a vector. You can do
df$itinary
or
It is slightly more than syntactic sugar for
sapply(x, function(m) {
m[["from"]]
})
We extended the idea in several ways:
1). We define a in-fix operator
2). We added error handling, in the case of bad indecies, etc.
A vector if all attributes can be converted to the same atomic class; or a list in the case that the values cannot be fit into a vector.
1 2 3 4 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.