The “c” Function in R

  • Package: Base R (no specific package required)

  • Purpose: Concatenates or combines objects to create a vector or list.

  • General Class: Data Manipulation

  • Required Argument(s):

    • Vectors, matrices, or other objects that you want to concatenate.

  • Notable Optional Arguments:

    • None

  • Example:

  • # Example data for using the c function
    numbers <- c(1, 2, 3)
    letters <- c("A", "B", "C")

    # Combine two vectors into a single vector
    combined_vector <- c(numbers, letters)

    # Display the result
    print(combined_vector)

  • In this example, the c function is used to combine two vectors (numbers and letters) into a single vector (combined_vector). The resulting vector contains the elements from both input vectors. The c function is a fundamental tool for creating vectors and lists in R by concatenating different elements.

Previous
Previous

The “data.frame” Function in R

Next
Next

The “seq_along” Function in R