How do you create a list with a single value in R? For example, I want a list of 50 zeros.
What is the easiest way to d开发者_运维百科efine this?How is a list of 50 zeros ~ a list with a single value?
Try this:
list(rep(0, 50))
Or if you want a list with fifty separate elements of zeros, you can do this:
as.list(rep(0, 50))
Maybe
res <- list(rep(0,50))
is all you need?
精彩评论