Skip to content

Instantly share code, notes, and snippets.

@kebbbnnn
Created October 7, 2016 13:14
Show Gist options
  • Save kebbbnnn/b56498f7a194557ea3700c62cd734e90 to your computer and use it in GitHub Desktop.
Save kebbbnnn/b56498f7a194557ea3700c62cd734e90 to your computer and use it in GitHub Desktop.
f3 <- function(m){
for(i in 1:nrow(m)){
for(j in 1:ncol(m)){
m[i,j] = if(m[i,j] %% 2 != 0) m[i,j]*2 else m[i,j]
}
}
return(m)
}
N <- matrix(c(c(1,5,-2),c(1,2,-1),c(3,6,-3)), ncol = 3, nrow = 3)
print(N)
print(f3(N))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment