To create a vector in R, one of the ways is to use the c() function. The c() function is S4 generic, but with argument list (x, …).
c Function in R
The c() is a built-in generic function that combines its arguments. The c function in R is used to create a vector with values you provide explicitly. The default method combines its arguments to form a vector.
All arguments are coerced to a common type of the returned value, and all attributes except names are removed.
c(…, recursive = FALSE, use.names = TRUE)
The c() function returns NULL or an expression or a vector of an appropriate mode.
In R, the c() function returns a vector.
rv <- c(19, 21) rv rv rv
 19 21  19  21
If you want to create a vector with 11 entries, use the following function.
data <- (1:11) print(data)
 1 2 3 4 5 6 7 8 9 10 11
Concatenate two vectors using c() function
To concatenate two vectors in R, use the c() function.
p <- c(1, 1) p <- c(1, 5) p <- c(p, c(1, 1.5)) p <- c(p, p) print(p)
 1.0 5.0 1.0 1.5 1.0 5.0 1.0 1.5
You can see that the output is a combined vector.
That is it for the c() function in R.