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? Thanks, Angel [[alternative HTML version deleted]]
You have typed a syntactically incomplete statement: this is explained in ?help. Hint: ?"for" and help("for") work. 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?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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
> I thought I was getting to grips with it, until last reply from Prof Brian > Ripley's. At least in my Windows and Linux boxesActually it was my reply that suggested ?paste("help")> ? paste("help") > opens the help for help (!?)Not on my systems! [Solaris, NetBSD, Windows 98]. I believe it should open the help for paste(). The point is that it requires a syntactically correct statement after the ? so that the command parses correctly (with ? as a unary operator), but the result is to provide the help for the first syntactic element of the parsed expression, *without* evaluating the expression. Ray Brownrigg