OneBite.Dev - Coding blog in a bite size

declare an array in R

Code snippet on how to declare an array in R

  fruit_types <- c("apple", "banana", "kiwi")

This code creates an array named “fruit_types” and assigns the values “apple,” “banana,” and “kiwi” to it. The “c” is a function used to combine multiple values into a single array. The resulting array can be used like any other variable in R, such as referencing its elements or looping through them. In this case, the array would have three elements, each representing a type of fruit.

r