-4

What is the difference between the following commands:

abc <- 1:15
abcd <- c(1:15)
abc
abcd

The output is:

> abc <- 1:15
> abcd <- c(1:15)
> abc
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
> abcd
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15

1 Answers1

3

c() is a function to concatenate vectors. In your example you only supply one vector - 1:15 so they are functionally the same.
You need c() if you want to concatenate two or more ranges, for example to not have 13 in your vector: c(1:12, 14:15)

Robin Gertenbach
  • 10,316
  • 3
  • 25
  • 37