I am new to R and have probably a very simple question... I am using the "source" function to read an R source file called, let's say, "first.r". This file was created in Notepad in Windows 2000. This is a simplistic example, but let's say in this file I have the following commands: x<-c(0,2,3,4,5,6) y<-mean(x) y When I run this source function I assumed that I would get a listing of the object "y" which is, of course, the mean of the "x" vector. It finds the source file and seems to create all the objects but does not act on the final command which simply asks it to list the value of "y". Why is this? I assumed the source function would simply run the "script" I had in this source file, command by command and list the value of "y". I can later issue a separate command:> yand get the value for y, but I cannot figure out how to make the script in the file give me this without having to go in manually and ask for it. Am I missing something? Is there a way to do what I want it to. Forgive my naivete...I am a SAS programmer taking baby steps in R!!! Thanks, Dave __________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 24 Oct 2002, DAVID JENSEN wrote: ...> > When I run this source function I assumed that I would > get a listing of the object "y" which is, of course, > the mean of the "x" vector. It finds the source file > and seems to create all the objects but does not act > on the final command which simply asks it to list the > value of "y". Why is this? I assumed the source > function would simply run the "script" I had in this > source file, command by command and list the value of > "y". I can later issue a separate command:Try: source('file', echo=TRUE) or print(y) in your script.> and get the value for y, but I cannot figure out how > to make the script in the file give me this without > having to go in manually and ask for it. > > Am I missing something? Is there a way to do what I > want it to. Forgive my naivete...I am a SAS > programmer taking baby steps in R!!!I'm a naive SAS programmer fighting with DATA and TRANSPOSE today. Dave -- Dave Forrest (434)924-3954w(111B) (804)642-0662h (804)695-2026p drf5n at virginia.edu http://mug.sys.virginia.edu/~drf5n/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 24 Oct 2002, DAVID JENSEN wrote:> Am I missing something? Is there a way to do what I > want it to. Forgive my naivete...I am a SASTry 'print(y)' -J -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._