IamWill
IamWill

Reputation: 35

In R, why are list(1:3) and list("a", "b","see") of different lengths?

In R, why does list(1:3) produce a list of length 1, but list("a","b","see") produces a list of length 3?

Upvotes: 0

Views: 59

Answers (1)

akrun
akrun

Reputation: 887971

It is the number of arguments. In the first, there is only a single argument and in the second, it is three and each argument would be an element in the list. To convert to length 3 by passing a single arugment, use the as.

as.list(1:3)

Upvotes: 3

Related Questions