How to create arrays in the R programming language?

To create an array in R language, you can use the array() function. This function takes multiple parameters, including the data vector, dimensions of the array, and dimension names.

Here is a simple example:

# 创建一个3x3的数组
arr <- array(1:9, dim = c(3, 3))

# 打印数组
print(arr)

This will create a 3×3 array with data from 1 to 9 and print it out.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds