I am new in R and I have a task to create list of lists.
I tried this:
newl <- list() newl <- append(newl, list(a = 1, b = "x")) newl <- append(newl, list(a = 15, b = "y")) newl <- append(newl, list(a = 10, b = "z")) But append works like extend Python function:
$a [1] 1 $b [1] "x" $a [1] 15 $b [1] "y" $a [1] 10 $b [1] "z" I want to get something like this:
[[1]] $a [1] 1 $b [1] "x" [[2]] $a [1] 15 $b [1] "y" [[3]] $a [1] 10 $b [1] "z" Also I want to have an opportunity to sort elements of my list of lists by parameter (for example, by a). It would look like this:
[[1]] $a [1] 1 $b [1] "x" [[2]] $a [1] 10 $b [1] "z" [[3]] $a [1] 15 $b [1] "y" Also it's important for me to have elements different types inside lists (int and string in the example). In real task it would be function, vector, double and matrix.
Maybe I need to choose another data type to solve my problem?