What are vectors?
6. Element vectors must be of same data type
Vector operations
Indexing and filtering
Simple analysis
Summary

Instruction

We're making good progress! What about mixing data types and storing both numbers and strings in one vector? It's not possible, as each vector must consist of elements that are of the same data type. There is a subtlety, though... if you try to mix data types in a vector, R will not complain. Instead, it will silently convert all values to a common data type. For example, the vector

salaries <- c(3100, "three thousand and four hundred", 2700)
will become a character vector. The numerical values (in this case, 3100 and 2700) will be automatically converted to the strings "3100" and "2700", respectively,  by R. Thus, when you type salaries into your editor, you'll get the following output:

[1] "3100" "three thousand and four hundred" "2700"

Exercise

Create a vector named employment_start_year that stores following elements: 2010, 2013, "nineteen ninety-nine", 2010, and 2000.

This vector stores the years in which the top five employees started working at Versico. Notice how R does not complain when you mix numerical and string data types — it just implicitly converts any numerical values to strings for consistency.

Stuck? Here's a hint!

You should assign the following vector to the employment_start_year:

c(2010, 2013, "nineteen ninety-nine", 2010, 2000)