Course Content

# R Introduction: Part I

1. Basic Syntax and Operations

R Introduction: Part I

## 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

- Assign the number
`10`

to a variable named`chapter`

. - Display the data type of the variable
`chapter`

.

Everything was clear?