To create vectors, several functions are available:

Vector()

C()

X <- c(0.2 , 0.5) |

X <- c(True, False)Â Â Â = c(1,0)Â Â = c(T, F) |

X <- 1:30 |

X <- vector(ânumericâ, length = 10)Â Â => Makes an empty vector with these properties |

Â

Different classes of basic objects (characters, numeric, integerâ¦) canât be mixed properly with this function, even if no error occurs. The data will be converted to type that corresponds to any element of the vector. For example, c(5, âtestâ, True) will actually be recorded as [â5â, âtestâ, â1â], because the character type is the least common denominator. This is Implicit Coercion.

It is possible though to change the type of an object manually with a function, here are some examples:

x <- as.numeric(x)Â Â Â => makes X a vector of numeric => Â If X is not translatable to numeric, it will give a vector of NA |

x <- as.logical(x)Â Â => Makes X a vector of Boolean logical |

x <- as.character(x)Â => Makes X a vector of characters |