[R] Usage questions

Thomas Lumley thomas at biostat.washington.edu
Thu Aug 10 19:12:35 CEST 2000


On Thu, 10 Aug 2000, Paul Johnson wrote:

> 
> Can I ask a couple of usage questions?  (RedHat Linux 6.1, R-1.1)
> 
> 1. This may just indicate I'm a dinosaur who can't leave SAS behind.  I
> want to write programs and run them with source() to see what they do,
> then I would like to use the "up arrow" to go back through the commands
> that were in the file, fiddle them, see what they do, and so forth.  Is
> there no way?  SAS has a functionality of a "program editor" screen
> where you can fiddle a  file, run it, then save it when it is the way
> you want. But in R I don't get any command history with source(), so I
> can't experiment with commands.

The best way to do this is to use Emacs and ESS (ess.stat.wisc.edu), which
gives various sorts of full-screen editing styles.
 

> 2. What does it mean when output from a command is just
> NULL

It means that the output is NULL :).  Usually this is because the function
is used for its side effects (like plot) and so the return value is
unimportant. Sometimes it is because NULL is the answer, eg a function
that returns a list which happens to be empty.

> It seems like everything is OK when this happens, but it does not always
> happen.

The first category of function often returns invisible(), which means that
the NULL isn't printed unless you explicitly ask for it: compare
	plot(1,1)
	print(plot(1,1))

Functions can also return large complicated objects invisibly.	

> 3.  When I tried
> >  postscript(file="test3.ps",onefile=FALSE)

The problem is that you asked for the files all to be called test3.ps.
This results in them being written on top of each other. Further down in
the postscript documentation it says that you need to give a printf-style
format that R can put the file number into

For example postscript(file="test3.%d.ps",onefile=FALSE)
gives files called test3.1.ps, test3.2.ps and so on.

> And then I ran some models, it did not create several files.  Where did
> I go wrong? I'm reading the postscript help page and it seems like
> there's something missing, or I'm illiterate, or both:
> 
>    postscript(file = ifelse(onefile, "Rplots.ps", "Rplot
>                 onefile = TRUE,
>                 paper, family, bg, fg, width, height, horizontal,
> pointsize,
>                 pagecentre, print.it, command))
> 
> The first line does not appear to be complete.

Yes. It's a bug.  The problem is that the file name is "Rplot%03d.ps" and
the % is a comment indicator in the R documentation format so the rest of 
the line disappears. Thanks for pointing it out.

You can find the arguments to postscript() by doing args(postscript) as
well, which doesn't have this problem

	-thomas

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