[R] source function help

DAVID JENSEN djense00 at yahoo.com
Fri Oct 25 01:06:09 CEST 2002


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:

> y

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!!!

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list