Like many other languages, R has a variety of basic types and more complex types that can be created from the 'atomic' ones. Basic types in R are:
- numeric (real)
Because R is a dynamically typed language you are able to convert variables values from one type to the other. This scenario introduces mechanisms of conversions in R.
Types conversions in R
There are two types of conversions in R: implicit and explicit. Implicit conversions happens without specifically introducing them by the programmer and when the direct conversion from one type to the other exists.
Take a look at the following example. Let's create a vector of integers ranging form 1 to 10:
a <- 1:10
As you may expect the type of the vector is integer:
Now let us put a value of some other type there:
a <- 'some text'
You can see that the type of the whole vector has changed as implicit conversion to string typed happened: