Kevin Wang wrote:
Hi,
On Thu, 30 Sep 2004, Jonathan Harris wrote:
I've written a program that involves a loop that creates a matrix. I'd like to be able to manipulate that matrix on my R desktop, but after I run the function, that matrix does not appear when I type ls(). How can I make that matrix become an object that I can manipulate?
If I understand you right, you want something like: foo <- function() { goo <- matrix(1:10, nrow = 5, ncol = 2) } then be able to call goo after running foo()? If this is what you want, then you need to do something like: foo <- function() { goo <<- matrix(1:10, nrow = 5, ncol = 2)
No, you don't want to do it that way, but you want to return(), in almost all cases I can imagine ...
Uwe
} to force goo to become a global variable, instead of a local variable to foo().
HTH,
Kevin
-------------------------------- Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia
Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
