What is the c() function in R?

Overview

The c() function in R is used to combine or concatenate its argument.

Syntax

c(…)

Parameter value

The c() function takes a parameter value , which represents the concatenated objects.

Return value

The c() function returns an expression or vector with an appropriate mode.

Example

a <- c(1, 2, 3)
b <- c(4, 5, 6)
mystring <- c(a, b)
mystring

Explanation

  • Lines 1 and 2: We take three values and concatenate them.
  • Line 5: We use the c() function to concatenate the values in the objects a and b.

Free Resources