[R] ?for

A.J. Rossini rossini at blindglobe.net
Fri Nov 21 03:04:10 CET 2003


"Angel" <angel_lul at hotmail.com> writes:

> I thought I was getting to grips with it, until last reply from Prof Brian
> Ripley's. At least in my Windows and Linux boxes
> ? paste("help")
> opens the help for help (!?)
> (But Marc is right, when you use emacs (in my Debian) instead of the shell
> it gives the error he says, anybody knows why?)

Yes.  Emacs/ESS takes stuff of the form ?name  and calls help("name")
on it.

This is a feature, not a bug.

best,
-tony

> For what I think I've learned, when you call ? it first evaluates the topic
> and then asks for help on the result, i.e. if you put a function after ? it
> will call help on the return value of that function, if it is a for or other
> type of flow control it will ask for help for each of the loop results. Is
> this the explicit reply to my original answer??
> Thanks,
> Angel
> ----- Original Message -----
> From: "Marc Schwartz" <MSchwartz at MedAnalytics.com>
> To: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
> Cc: "Ray Brownrigg" <ray at mcs.vuw.ac.nz>; <r-help at stat.math.ethz.ch>;
> <angel_lul at hotmail.com>; <p.dalgaard at biostat.ku.dk>
> Sent: Monday, November 17, 2003 9:58 PM
> Subject: Re: [R] ?for
>
>
>> On Mon, 2003-11-17 at 14:27, Prof Brian Ripley wrote:
>> > Well ^C or ESC (on Windows GUI) is the answer I would give.
>> >
>> > On Tue, 18 Nov 2003, Ray Brownrigg wrote:
>> >
>> > > Peter Dalgaard <p.dalgaard at biostat.ku.dk> writes:
>> > > >
>> > > > Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
>> > > >
>> > > > > You have typed a syntactically incomplete statement: this is
> explained in
>> > > > > ?help.
>> > > > >
>> > > > > Hint: ?"for" and help("for") work.
>> > > >
>> > > > [Original question added back in:
>> > > > On Sun, 16 Nov 2003, Angel wrote:
>> > > >
>> > > > > I have always been intrigued by why ?for (or ?if,?while,etc) leave
> R
>> > > > > wanting for more:
>> > > > > > ?for
>> > > > > +
>> > > > > I know the help for these is in ?Control, but I sometimes make the
>> > > > > mistake of typing ?for instead. What is R expecting me to say to
> finish
>> > > > > the statement?
>> > > > ]
>> > > > Further hint: ? is an operator, syntactically similar to + and -.
> You
>> > > > can apply operators to the result of a for loop. Consider for
> example
>> > > >
>> > > > x <- 1; - for (i in 1:10) x <- x * i
>> > > >
>> > > > (? has special semantics, but that is not noticed at parse time).
>> > > >
>> > > Unfortunately the original question still hasn't been answered
>> > > explicitly, not even in ?help.
>> > > Try:
>> > > > ?for
>> > > + (i in 0) 0
>> > > or:
>> > > > ?if
>> > > + (T) T
>> > > or:
>> > > > ?+
>> > > + 0
>> > >
>> > > So you have to provide the rest of a syntactically complete statement.
>> > >
>> > > Just to see if you now understand exactly how ? works, what do you
>> > > think:
>> > > ? paste("help")
>> > > will do?
>> > >
>> > > Ray Brownrigg
>>
>>
>> R 1.8.1 Beta using gnome-terminal on Fedora Core 1 gives:
>>
>> > ? paste("help")
>> help() for paste  is shown in browser /usr/bin/mozilla ...
>> Use      help( paste , htmlhelp=FALSE)
>> or       options(htmlhelp = FALSE)
>> to revert.
>>
>>
>> However, using ESS with emacs on the same platform gives:
>>
>> > ? paste("help")
>>
>> Error in help("paste(", htmlhelp = FALSE) :
>> No documentation for 'paste(' in specified packages and libraries:
>>   you could try 'help.search("paste(")'
>>
>>
>> :-)
>>
>> Marc
>>
>>
>>
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

-- 
rossini at u.washington.edu            http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN          Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}




More information about the R-help mailing list