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

后端 未结 2 659
醉梦人生
醉梦人生 2021-01-17 08:02

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 define this?

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 08:30

    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))
    

提交回复
热议问题