[R-wiki] Be careful of syntax!
Philippe Grosjean
phgrosjean at sciviews.org
Wed Feb 1 17:42:40 CET 2006
Tony Plate wrote:
> 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.
Good point, you are perfectly right! I will cook a 'rtrans' syntax
highlighting for GeSHi for this purpose.
> 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"?
Certainly possible through the DokuWiki export function. One "just" has
to write the "R code only" export function. This is on the TODO list.
So, it means that it will not be too much of a problem to use R session
transcript and collect R code from it, outside of the specific function
of RGui.
> 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
>
Philippe Grosjean
More information about the R-sig-wiki
mailing list