[R] how to initial a list to store data result?
David Winsemius
dwinsemius at comcast.net
Tue Jun 22 01:26:19 CEST 2010
On Jun 21, 2010, at 7:18 PM, song song wrote:
> May I ask how to initialize a list?
>
> usually I will use " result=list(0) " to do this. is this right?
There is now something in that list, namely an element whose value is
zero. If you append to it with the c() function, the 0 will still be
there.
> result=list(0)
> result=c(result, 5)
> result
[[1]]
[1] 0
[[2]]
[1] 5
What's wrong with
result=list()
result=c(result, 5)
> result
[[1]]
[1] 5
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list