0
我正在製作一個函數來獲取一個顏色矢量和一個3x3x6數組。這將是一個rubiks立方體。我正在使用該函數來查看多維數據集是否已解決。我無法讓函數使用傳遞給它的顏色矢量和數組。如何使一個函數接受一個數組
cube = function(color, cube){
#Description:
#Args:
#Returns:
array = array(color,cube)
if(!dim(array)[1] == 3 | !dim(array)[2] == 3 | !dim(array)[3] == 6){
print("Please enter a cube of 3 by 3 by 6")
}
if(!array[1] == 'red' | !array[2] == 'blue' | !array[3] == 'green' |
!array[4] == 'yellow' | !array[5] == 'white' | !array[6] == 'orange'){
print("Please enter a valid 6 colors for the cube")
}
#need more code here to check if the cube is solved
}
cube(c('red','blue','green','yellow','white','orange'), dim=c(3,3,6))
這是我得到的錯誤。
Error in cube(c('red','blue','green','yellow','white','orange'), dim = c(3, 3, 6)) : unused argument (dim = c(3, 3, 6))
感謝
嘗試在調用'cube(...)時去除'dim =' – xxfelixxx
工作!謝謝 – packerfan