OneBite.Dev - Coding blog in a bite size

create an array of string in R

Code snippet on how to create an array of string in R

  my_names <- c("John", "Emily", "Ryan")

This code creates an array of strings in R. The variable “my_names” is assigned a vector with three elements, “John”, “Emily”, and “Ryan”, using the c() function. The c() function is useful for quickly creating a vector of elements. In this case, the vector created contains three strings, representing the names John, Emily, and Ryan. Elements in the vector can be accessed in the same way as elements in an array, by referring to the element’s index. For instance, accessing the first element of the vector “my_names” would be done with the code “my_names[1]”, which would return the value “John”.

r