Types of vectors

Vectors can only hold elements of the same data type. In this course we will work with the following three main data types:

Numeric values are numbers. Although they can be further split into whole numbers (integers) and numbers with decimals (doubles), R automatically converts between these sub-types if needed. Therefore, we will collectively refer to them as just numeric values.

Character values contain textual content. These can be letters, symbols, spaces and numbers as well. They must be enclosed by quotation marks - either single quotes '___' or double quotes "___".

Logical values can either be TRUE or FALSE. They are also often referred to as boolean or binary values. Because a logical value can only be TRUE or FALSE they are most often used to answer simple questions like “Is 1 greater than 2?” or “Is it past 3 o’clock?”. These kind of questions only need answers like “Yes” (TRUE) or “No” (FALSE). Importantly, in R logical values are case sensitive, which means they have to be written with capital letters.

Combine values into a vector