[R-wiki] Be careful of syntax!
Philippe Grosjean
phgrosjean at sciviews.org
Wed Feb 1 13:19:51 CET 2006
Hello all,
Thanks a lot for your contributions. I know that a Wiki page is
relatively free. However, please, note the following when adding pages
(keep in mind that these pages will be examples for others)!
- Always use a H1 title (title level 1, using ====== Title 1 ====== (six
equal signs) at the top of the page
- Sign just under (register, and you got thne convenient signature
button at the far right of the button bar)
- Try to format R code as the implicit "R-Core Team formatting", in
particular:
+ Forget about T/F and always use TRUE/FALSE
+ Forget about '=' for assignation ands always use '->'
+ Use spaces for clearer code in math operations, after commas,
between the equal sign in named arguments, for instance:
f <- function(x, y, nam.rm = TRUE) {
if (na.rm) {
x <- na.omit(x)
y <- na.omit(y)
}
x + log(y)^2 - y
}
+ Indent (use four spaces for each indentation instead of tabs, to
make sure it is correct)
+ Bracket indentation should be as the example here above.
+ Use named arguments as much as possible, because it is more explicit)
+ Use meaningful variable names
- 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>
and yet better than:
<code r>
a <- 1:4
a [1] 1 2 3 4
</code>
- Finally, note that there is quote mechanism in the Wiki, so that:
Mr X said:
> This is what Mr X said
Mr Y answered:
> This is the answer...
> Even more Mr Y answer.
Best,
Philippe Grosjean
More information about the R-sig-wiki
mailing list