How can arrays’ average values be calculated in the R language?
In R language, you can use the function mean() to calculate the average of an array. For example, you can calculate the average of an array containing numbers like this:
# 创建一个包含数字的数组
nums <- c(1, 2, 3, 4, 5)
# 计算数组的平均值
average <- mean(nums)
# 输出结果
print(average)
The above code calculates the average of the array nums and stores the result in the variable average, then prints the result using the print() function.