Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What is a Vector?
course content

Course Content

R Introduction: Part I

What is a Vector?What is a Vector?

If you're already acquainted with programming, you might have a notion of what a vector is. In straightforward terms, it's akin to an array where multiple values can be stored. But why is it that we should dive into data types starting with something akin to arrays?

The reason is quite straightforward – even single entities like numbers (whether they be real, integers, or complex) or a text string are treated as vectors, albeit with a length of one. So, let's set aside the notion of single-element vectors for the moment. Which types are recognized in R? The list includes:

  • logical – for storing Boolean values TRUE/T and FALSE/F.
  • numeric/double – for real numbers.
  • integer – for whole numbers.
  • complex – for numbers with both real and imaginary parts.
  • character – for textual data (strings).

To determine the type of a given variable, you would employ the typeof() function, providing the variable in question as an argument. For example:

Take the initiative to practice this function on your own!

Task

  1. Assign the number 10 to a variable named chapter.
  2. Display the data type of the variable chapter.

Everything was clear?

Section 2. Chapter 1
Switch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt