Message-ID: <1132058124.4819.51.camel@localhost.localdomain>
Date: 2005-11-15T12:35:24Z
From: Tom
Subject: changing the value of a variable from inside a function
In-Reply-To: <5.2.1.1.1.20051115115224.0198f800@imap.duke.edu>
Michael,
I feel sure people are going to come up with other better suggestions
here but does <- work for you?
test <- matrix(NA,nrow=4,ncol=3)
test[1,] <- c(1,2,3)
blah <- function(i){
test[i,] <<- c(0,1,2) + i
return(test)
}
On Tue, 2005-15-11 at 12:22 -0500, Michael Wolosin wrote:
> test <- matrix(NA,nrow=4,ncol=3)
> test[1,] <- c(1,2,3)
> blah <- function(i){
> test[i,] <- c(0,1,2) + i
> return(test)
> }
> test
> blah(2)
> test