[R-es] ¿Reglas de estilo para código en R?
Carlos J. Gil Bellosta
cgb en datanalytics.com
Jue Jun 7 16:27:20 CEST 2012
Hola, ¿qué tal?
Ya hace un tiempo traduje y mínimamente adapté las reglas de estilo de
R de Google. Las colgué en
http://www.datanalytics.com/guia_estilo_r.html
Y creo que algo comenté por aquí.
Un saludo,
Carlos J. Gil Bellosta
http://www.datanalytics.com
2012/6/7 Xavier de Pedro <xavier.depedro en vhir.org>:
> Hola:
>
> Me suena algo de que el año pasado alguien dijo algo sobre unas
> sugerencias de reglas de estilo para escribir código en R.
> No he oído nada más en esta lista (a lo mejor se me ha pasado por alto)
>
> Ayer se publicó un mensaje sobre esto precisamente en un blog en inglés:
>
> http://pairach.com/2012/06/06/r-style-guide/ (copiado debajo para
> facilitar la lectura y comentarios en esta lista)
>
>
> ¿Qué reglas de stilo recomendáis o usáis las personas de esta lista?
>
> ¿Podríamos sugerir algo de consenso para la comunidad en castellano y
> demás lenguas latinas afines? (evitar ñ, ç, ...)
>
> Xavier
>
>
> R Style Guide
>
> by Pairach on June 6, 2012
> 4 Votes
>
> Having a systematic and consistent guide is important for programming,
> so does in R.
>
> Here are some recommended style guides for programming in R.
>
> Pick one of them and strictly follow it.
>
>
> 1. Google's R Style Guide
>
> * Link to Google's R Style Guide (official URL
> <http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html>,pdf
> <http://piboonrungroj.files.wordpress.com/2012/06/googles-r-style-guide.pdf>)
> * Providing 14 R Style Rules including filenames,
> identifiers, indentation, spacing etc.
> /"These rules were designed in collaboration with the entire R user
> community at Google"/
>
>
> 2. Henrik Bengtsson's R Coding Conventions
> <http://www.maths.lth.se/help/R/RCC/>
>
> * Link to R Coding Conventions <http://www.maths.lth.se/help/R/RCC/>
> * Developed since 2002. It's version 0.9 (January 2009)
> * Please read this message in the introduction part before applying
> this coding convention.
>
> " /Please note that this document is under construction since mid
> October 2002 and should still be seen as a first rought draft.
> There is no well defined coding recommendations for the R language
> [1] and neither is there a de facto standard. This document will
> give some recommendations, which are very similar to the ones in the
> Java programming style [2][3], which have found to be helpful for
> both the developer as well as the end user of packages and functions
> written in R./"
>
>
> 3. Hadley Wickham's Style Guide
>
> * Link to his R style guide atGitHib wiki of devtool package
> <https://github.com/hadley/devtools/wiki/Style> and had.co.nz
> <http://stat405.had.co.nz/r-style.html>
> * Mainly based on the Google's style.
>
> Here is what he mentions in the introduction.
> "Good coding style is like using correct punctuation when writing:
> you can manage without it, but it sure makes things easier to read.
> As with punctuation, there are many possible variations, and the
> main thing is to be consistent. The following guide describes the
> style that I use -- you don't have to use it, but you need to have
> some consistent style that you do follow. My style is based on
> Google's R style guide, with a few tweaks.Good style is important
> because while your code only has one author, it will usually have
> multiple readers, and when you know you will be working with
> multiple people on the same code, it's a good idea to agree on a
> common style up-front."
>
>
> 4. R Core's coding standard
>
> * Official R coding standard
> <http://cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards> in
> R Internals Manual <http://cran.r-project.org/doc/manuals/R-ints.html>
>
>
> 5. formatR package
>
> * Links to the package's
> CRAN<http://cran.r-project.org/package=formatR>, GitHub
> <https://github.com/yihui/formatR/wiki> site
> * One can also use Yihui'sformatRpackage to tidy R codes with function
> tidy.source().
> * Package description is as follows
>
> "The *formatR* <http://cran.r-project.org/package=formatR> package
> was designed to reformat R <http://www.r-project.org/> code to
> improve readability; the main workhorse is the function
> |tidy.source()|. Features include:
>
> * long lines of code and comments are reorganized into
> appropriately shorter ones
> * spaces and indent are added where necessary
> * comments are preserved in most cases
> * the number of spaces to indent the code (i.e. tab width) can be
> specified (default is 4)
> * an |else| statement in a separate line without the leading
> |}| will be moved one line back
> * |=| as an assignment operator can be replaced with |<-"|
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-help-es mailing list
> R-help-es en r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
Más información sobre la lista de distribución R-help-es