c(): combine values into a vector or a list

The function c is a widely used function to combine values into a vector or a list. The default method combines its arguments to form a vector. All arguments are coerced to a common type which is the type of the returned value, and all attributes except names are removed.

The basic usage of c function is written in the exercise.

Instruction

  • Assign the values and use c function to combine x and y into z.
# Using c function to combine two vectors c(1,7:9) # It can be used to combine multiple types of vectors c(1:5, 10.5, "next") # Assign "University of Alabama" to x and Assign "Educational Psychology" to y x <- y <- # Combine x and y into z z <- # Using c function to combine two vectors c(1,7:9) # It can be used to combine multiple types of vectors c(1:5, 10.5, "next") # Assign "University of Alabama" to x and Assign "Educational Psychology" to y x <- "University of Alabama" y <- "Educational Psychology" # Combine x and y into z z <- c(x, y) test_object("x", undefined_msg = "Make sure to define a variable `x`.", incorrect_msg = "Make sure that you assign the correct value to `x`.") test_object("y", undefined_msg = "Make sure to define a variable `y`.", incorrect_msg = "Make sure that you assign the correct value to `y`.") test_object("z", undefined_msg = "Make sure to define a variable `z`.", incorrect_msg = "Make sure that you assign the correct value to `z`.") success_msg("Great! Head over to the next exercise.")

Previous: 1-9 | example(): Run the examples in the help document

Next: 1-11 | seq(): Sequence function

Back to Main