quick question. My List (in R) looks like:
> mylist
$width
[1] 32
With mylist[1] I get:
$width
[1] 32
But how do I get:
$width
Thanks and cheers.
HASH VALUES can be any R value, vector or object. code {hash} returns a hash object. Key-value pairs may be specified via the ... argument as explicity arguments keys and values, as named key-value pairs, as a named vector or as implicit key, value vectors.
Key-value pairs may be specified via the ... argument as explicity arguments keys and values, as named key-value pairs, as a named vector or as implicit key, value vectors. See examples below for each type. See .set for further details and how key-value vectors of unequal length are interpretted.
PASS-BY REFERENCE. Environments and hashes are special objects in R because only one copy exists globally. When provided as an argument to a function, no local copy is made. When passes to functions, those functions can change the value of the hash. This is not typical of R.
The names of elements are stored in an attribute called "names", which can be accessed via the names
function.
Try this:
mylist <- list(width=42, height=13)
names(mylist) # "width" "height"
names(mylist)[1] # "width"
mylist[["width"]] # 42
mylist[sort(names(mylist))] # sort mylist by the names...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With