[R] Add elements to a global list
Khanvilkar, Shashank
skhanvil at qualcomm.com
Tue Sep 6 22:47:09 CEST 2011
Hello All,
Thanks in advance for all help.
In my prog, I have a global list object that is used as a container for storing some data frames.
Here is an example code.
--SNIP--
temp1 <- function(X){
statName = c("Mean", "stdDev", "NumSamples")
statVal = c("0.5", "0.51", "5")
r = data.frame(statName=statName, statVal = statVal)
X[["temp1"]] = r
}
reportList = list()
temp1(reportList)
print(reportList)
--SNIP--
I was expecting that the new data frame in temp1 would get added to the list (reportList), but it doesn't, probably because, arguments to functions are passed "Call-by-value" and loose all locally made changes.
Any ideas how I can do this.
Shank
More information about the R-help
mailing list