briandk / granovaGG

Bob Pruzek and Jim Helmreich's implementation of Elemental Graphics for Analysis of Variance
Other
15 stars 4 forks source link

Functions should adopt a consistent style for code formatting #19

Closed briandk closed 13 years ago

briandk commented 13 years ago

Here are a few non-exhaustive samples of inconsistencies in our code formatting.

I take full responsibility for all of them, but I think we should discuss how we prefer to handle each of the inconsistencies, and adopt that throughout the code.

These inconsistencies were found as of commit: https://github.com/briandk/granova/commit/697c212e15a51837018f4c3b5e78c00905b49c41

Spacing in function declarations

identityLine <- function() {
title <- function () {
initializeGgplot <- function(dsp) {
scaleX <- function (dsp) {

return calls

return( geom_abline(
return (rawData)

indentation:

CIBand <- function (dsp) {
  CIBand <- geom_segment(
    aes(
     x     = cx,
     y     = cy,
     xend  = cxend,
     yend  = cyend,                        
     color = color
    ), 
            size  = I(2),
            data  = dsp$CIBand
          )

spacing following parentheses:

return (   t.test(data[, 1], 
                  data[, 2], 
                  paired     = TRUE,
                  conf.level = conf.level
           )

parentheses alignment:

return(  data.frame(
          lowerTreatmentEffect = as.numeric(tTest$conf.int[2]),
          meanTreatmentEffect  = as.numeric(tTest$estimate[1]),
          upperTreatmentEffect = as.numeric(tTest$conf.int[1]),
          tStatistic           = as.numeric(tTest$statistic[1])
        )
WilDoane commented 13 years ago

Shall we simply adopt http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html as much as possible?

I think that would make the above code look more like

Spacing in function declarations

identityLine <- function() {
title <- function() {                 
initializeGgplot <- function(dsp) {
scaleX <- function(dsp) {             

return calls

return(geom_abline(                 
return(rawData)                     

indentation:

CIBand <- function(dsp) { 
  CIBand <- geom_segment(aes(x     = cx,
                             y     = cy,
                             xend  = cxend,
                             yend  = cyend,                        
                             color = color
                            ), 
                         size  = I(2),
                         data  = dsp$CIBand
                        )

spacing following parentheses:

return(t.test(data[, 1], 
              data[, 2], 
              paired     = TRUE,
              conf.level = conf.level
             )

parentheses alignment:

return(data.frame(lowerTreatmentEffect = as.numeric(tTest$conf.int[2]),
                  meanTreatmentEffect  = as.numeric(tTest$estimate[1]),
                  upperTreatmentEffect = as.numeric(tTest$conf.int[1]),
                  tStatistic           = as.numeric(tTest$statistic[1])
                 )
WilDoane commented 13 years ago

granova.ds.ggplot now follows the Google R Style Guide