开发者

How do you create a list with a single value in R?

开发者 https://www.devze.com 2023-01-22 18:31 出处:网络
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?

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消