In R, you can declare an array using the c() function or by specifying values directly.
In this example,
numbers
using the c()
function and initialize it with some values.numbers <- c(1, 2, 3, 4, 5)
print(numbers)
[1] 1 2 3 4 5
In this example,
fruits
by specifying values directly.fruits <- c('Apple', 'Banana', 'Orange')
print(fruits)
[1] "Apple" "Banana" "Orange"
In this tutorial, we learned How to Declare an Array in R language with well detailed examples.