Setting vector as a list component in R -


I want to create a list which has 1 element called 'A' in which there is a vector of doubles.

  l < -list ('a' = 1: 1000)   

does the trick though, what if I want to do it dynamically?

  l < -list () L ['A'] & lt; -1: 1000   

does not work! How can I assign enough memory when creating a list? Thanks

then you do

  & gt; L & lt; -list () & gt; L [['A']] & lt; -1: 10 & gt; L $ a [1] 1 2 3 4 5 6 7 8 9 10   

With lists that work well, [...] you are given a list with the selected elements Where [[...]] gives you the selected element help page remove

Edit: Or, as Tim said, l $ a & Lt; - 1:10 does the advantage of [[...]]

  & gt; L & lt; - List () & gt; Aname & lt; - 'a' & gt; L [[Anam]] & lt; - 1:10 & gt; L $ a [1] 1 2 3 4 5 6 7 8 9 10    

Comments