I have a list (tmpList), which looks like this:
$op
[1] "empty"
$termset
$termset$field
[1] "entry"
$termset[[2]]
$termset[[2]]$explode
[1] "Y"
This is a list with a list inside. If I add this list to a vector
theOneVector = c(theOneVector, tmpList)
Now the resulting vector is of the length 2, because the first entry ("op") of the list is separated from the tmpList.
Is it possible to append the complete tmpList into this vector?
I already tried it with
theOneVector = c(theOneVector, list(tmpList))
which gives a vector with the length of 1, but it is very cumbersome to access the elements of the list with this extra list around the list. (Too much list in one sentence I think.)
Any help would be appreciated,
Martin
How to create a list in R programming? List can be created using the list() function. Here, we create a list x , of three components with data types double , logical and integer vector respectively. Its structure can be examined with the str() function.
To convert List to Vector in R, use the unlist() function. The unlist() function simplifies to produce a vector by preserving all atomic components.
You can stick a vector (a restricted structure where all components have to be of the same type) into a list (unrestricted). But you cannot do the reverse.
To create combination of multiple vectors, we can use expand. grid function. For example, if we have six vectors say x, y, z, a, b, and c then the combination of vectors can be created by using the command expand. grid(x,y,z,a,b,c).
You can stick a vector (a restricted structure where all components have to be of the same type) into a list (unrestricted).
But you cannot do the reverse. Use lists of lists of lists ... and then use lapply et al to extract.
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