[R] Problem w/ source

2003-07-24 Thread Peter Muhlberger
I'm trying to use the source command to run commands from a file.  For
instance:  source(do.R), where do.R is a file in the same directory in
which I am running R.

The contents of do.R are:

ls()
print(hello)
sum(y1)
mean(y1)


After  source(do.R), all I see is:

 source(do.R)
[1] hello


I'm using the X11 version of R for Mac OS X (downloadable binary).  Does
anyone know how to get source to work?

Thanks!

Peter

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problem w/ source

2003-07-24 Thread Uwe Ligges
Peter Muhlberger wrote:

I'm trying to use the source command to run commands from a file.  For
instance:  source(do.R), where do.R is a file in the same directory in
which I am running R.
The contents of do.R are:

ls()
print(hello)
sum(y1)
mean(y1)
After  source(do.R), all I see is:


source(do.R)
[1] hello

I'm using the X11 version of R for Mac OS X (downloadable binary).  Does
anyone know how to get source to work?
Thanks!

Peter



Works perfectly, but no automatic print() is executed as the default 
when sourcing. When you want the other objects to be printed either use
  print(ls())
  print(sum(y1))
  ...
or use
  source(do.R, print.eval = TRUE)
as described in ?source.

Uwe Ligges

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problem w/ source

2003-07-24 Thread Duncan Murdoch
On Thu, 24 Jul 2003 10:42:05 -0400, Peter Muhlberger
[EMAIL PROTECTED] wrote :

I'm trying to use the source command to run commands from a file.  For
instance:  source(do.R), where do.R is a file in the same directory in
which I am running R.

The contents of do.R are:

ls()
print(hello)
sum(y1)
mean(y1)


After  source(do.R), all I see is:

 source(do.R)
[1] hello


I'm using the X11 version of R for Mac OS X (downloadable binary).  Does
anyone know how to get source to work?

You probably want 

source(do.R, echo = TRUE)

or maybe not; see ?source.

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problem w/ source

2003-07-24 Thread Douglas Bates
Well, we feel that source does work the way that it is documented to
work.  Please read the documentation and notice that the entire file
is evaluated as one step in the read-eval-print loop.  If you want to
print the results of individual function calls you will need to change
your script to

print(ls())
print(hello)
print(sum(y1))
print(mean(y1))

Peter Muhlberger [EMAIL PROTECTED] writes:

 I'm trying to use the source command to run commands from a file.  For
 instance:  source(do.R), where do.R is a file in the same directory in
 which I am running R.
 
 The contents of do.R are:
 
 ls()
 print(hello)
 sum(y1)
 mean(y1)
 
 
 After  source(do.R), all I see is:
 
  source(do.R)
 [1] hello
 
 
 I'm using the X11 version of R for Mac OS X (downloadable binary).  Does
 anyone know how to get source to work?
 
 Thanks!
 
 Peter
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problem w/ source

2003-07-24 Thread Peter Muhlberger
Thanks to everyone for their suggestions on getting source to print!  It
seems not everyone was aware of a couple options that gets source to print
out everything.  I'm now using the following command:

source(do.R, print.eval=TRUE, echo=TRUE)

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help