stefx
stefx

Reputation: 55

How to create a list with several entries

I want to create a list with 1000 files including all just containing the value 20 (7 times).

For example

[1] 20 20 20 20 20 20 20

[2] 20 20 20 20 20 20 20

...

[1000] 20 20 20 20 20 20 20

result = list(rep(20,7))

This way I just create one list.

result = as.list(rep(20,1000))

And this way I create 1000 lists containing just one entry. I tried to implement two "rep" functions. For example

result = as.list(rep(rep(20,7), 1000))

But unfortunately it does not work.

Upvotes: 0

Views: 32

Answers (1)

joran
joran

Reputation: 173627

Something like this, perhaps:

x <- replicate(1000,rep(20,7),simplify = FALSE)

Upvotes: 2

Related Questions