Skip to content
Back to formatted view

Raw Message

Message-ID: <396552.90571.qm@web56008.mail.re3.yahoo.com>
Date: 2009-11-06T22:43:25Z
From: Jason Rupert
Subject: Function Value Not Being Overwritten?

Part of my problem is that I am in the middle of starting to use functions, so this was unexpected behavior for me.? Maybe there is a work-around because I like declaring some of the variables prior to using them.?? 

I have two separate files: 

# File: Test.R
dog<-function(x)
{
??? templeton<-NULL
??? source("Cat.R")
??? print(templeton)
??? print(x)
??? 
??? print(bobby)
}




# File Cat.R
templeton<-c(7)
bobby<-c("This", "is", "a", "test.")



Now running the function in the RGui...
> source("Test.R")
> dog(13)
NULL
[1] 13
[1] "This"? "is"??? "a"???? "test."


My question is why is "templeton" equal to NULL?? 

I expected "templeton" to be equal to "7".? Notice that bobby came across fine. 

Is there anyway for the value of "templeton" set in Cat.R to come across successfully? 

Thanks for any feedback and insights.