转换由n个整数元素组成的一维数组,使前半部分包含奇数位置的元素,下半部分包含偶数位置的元素。
源数组:(1,6,2,5,4)
经过处理后,我需要这个:(1,2,4,6,5)
发布于 2022-06-10 12:47:48
尝试使用sort()函数:
就像这样:
# create a linear array
arr <- c(9, 8, 7, 6, 5, 4, 3, 2, 1)
# use of sort function to sort array
# by default it is sorted in increasing order
sort(arr)
# Output: [1] 1 2 3 4 5 6 7 8 9看看这个教程。
https://stackoverflow.com/questions/72574455
复制相似问题