Hi KB
I am not sure exactly what you want to do but perhaps this is this closer to what you need: addition<-function(X, a){Xnew<-X + a} X<-array(1,dim=c(2,2)) a<-2 Xa<-addition(X,a) Xa Regards JS --- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Konrad BLOCHER Sent: 05 February 2008 15:52 To: r-help@r-project.org Subject: [R] modifying arrays within functions Hi, I'm pretty new to R and seem to be having difficulties with writing a function that would change an array and keep the change after the function finishes its work. in other words I have an array of 1's X<-array(1,dim=c(2,2)) I want to add a number to X[1,1] by means of a function called addition. What I am writing is: addition<-function(a){X[1,1]=X[1,1}+a} but it doesn't seem to work Any ideas? Please? :) Thanks KB ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.