[R] modifying arrays within functions

From: Konrad BLOCHER <kb25532_at_sgh.waw.pl>
Date: Tue, 5 Feb 2008 16:49:41 +0100 (CET)


Hi,

I'm preetty 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_at_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. Received on Tue 05 Feb 2008 - 16:02:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Feb 2008 - 16:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive