[R-wiki] Be careful of syntax!
Tony Plate
tplate at acm.org
Wed Feb 1 17:32:05 CET 2006
Philippe Grosjean wrote:
> [snip]
> - Try to write code directly executable in R in <code r></code> chunks.
> For instance:
> <code r>
> a <- 1:4
> a # [1] 1 2 3 4
> </code>
>
> is better than:
> <code r>
> > a <- 1:4
> > a
> [1] 1 2 3 4
> </code>
>
I like examples that are transcripts (i.e., not just the input code),
and I suspect that transcripts are easiest to understand for beginners.
The R windows gui (the command window) has the ability to take a
transcript from the clipboard and extract and execute just the commands
in it (for simple commands that don't involve reading input or using
other types of prompts). So at least for Windows users, examples that
are transcripts can be easily executed.
I wonder if it's possible for the wiki to serve up extracted commands
from examples, e.g., a button beside the example that has the function
"copy commands from transcript to viewer's clipboard"?
Not a high priority, but if something like that might be possible in the
future, then there would be no need to encourage contributors to put in
input-only style examples.
-- Tony Plate
More information about the R-sig-wiki
mailing list