Hi all, I am having trouble assigning a value within a vector using a variable defined within a function. I suspect this has something to do with namespaces but I cannot figure it out. Please reply directly to me if you can help.
###begin code #simple vector test<-c(4,5,6) #simple function to get a value from a vector #works just like I would expect, has no problem indexing using the local function variable name "index" getvalue<-function(index){ print(test[index]) } getvalue(2) #another simple function to update the value in a vector update<-function(index){ test[index]<- 20 } update(2) test #The update() function silently fails to accomplish the update ### I don't understand why the function has no problem accessing the value, but cannot accomplish the assignment. I need to be able to update vectors using index values which I pass from within a function. Thanks for your help. Andrew Barr [[alternative HTML version deleted]] ______________________________________________ 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.