I'm more used to a python environment. Is there a way to produce a dictionary/list that is fully dynamic. I.e. that I could create flexible data structures say that relate to a particular number such as
[1:["var_a":6, "var_b":3],2:[..]]
Where I will not know how may elements in each list. Is there a way to do this?
> a <- list()
> a[[1]] <- list(var_a=6)
> a[[1]]$var_b = 3
> a[[2]] <- list(var_c=8)
> a[[1]]
$var_a
[1] 6
$var_b
[1] 3
> a[[1]]["var_b"]
$var_b
[1] 3
> a[[2]]$var_c
[1] 8
As @JulianUrbano says, a list
is a flexible data structure in R.
It's a vector:
l <- list()
is.vector(l)
That can take names:
l2 <- list( a = 1 , l = l )
l2[["a"]]
l2[1:2]
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