Skip to content

Instantly share code, notes, and snippets.

@chao1224
Created February 20, 2018 07:22
Show Gist options
  • Save chao1224/cf9ec33356dc7b9319c3cdd9ae925d6d to your computer and use it in GitHub Desktop.
Save chao1224/cf9ec33356dc7b9319c3cdd9ae925d6d to your computer and use it in GitHub Desktop.
r = 5
c = 10
matrix_ = matrix(0, r, c)
assign <- function(matrix_, r, c){
count = 1
for (i in 1:r) {
for (j in 1:c) {
matrix_[i,j] = count
count = count + 1
}
}
return(matrix_)
}
matrix_ <- assign(matrix_, r, c)
args = commandArgs(trailingOnly = TRUE)
index = as.numeric(args[1])
#print(index)
complete_index = c(1, 2, 3, 4, 5, 6, 7, 8)
temp_index = combn(8, 4)
print(temp_index)
temp_index = temp_index[, index]
print(matrix_[, temp_index])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment