[R-wiki] Be careful of syntax!
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Feb 1 14:48:09 CET 2006
Philippe Grosjean <phgrosjean at sciviews.org> writes:
> - 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
And of course, make sure that the code actually works (the above
does not in two different ways...)
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-sig-wiki
mailing list