1. Learn
  2. /
  3. Courses
  4. /
  5. Linear Algebra for Data Science in R

Exercise

Creating Vectors in R

Vectors can be analyzed in a few different ways in R.

One way is to create the vector yourself, and there are a few different means by which you can do this.

The rep() command in R creates a vector that repeats the same element a prescribed number of times, while the seq() command creates a vector that follows a prescribed pattern.

A vector can be manually created by using the c() command, which stands for "concatenate".

Instructions

100 XP
  • Use the example creating a vector of three 3's to create a vector of four 4's using the rep() command.

  • Use the example creating the vector containing the numbers 2, 4, and 6 in order, to create the vector containing 1, 3, and 5 in order using the seq() command.

  • The prompts to the first two questions have been created using the c() command. Provide the answers to the first two the same way, using the c() command.