Domanda

I do not like the automatic indentation of comments in ESS (Emacs Speaks Statistics) mode, because it is so far to the right.

normalize <- function(values){
                                        # comment
  return(2* values / (max(values) - min(values)) )
}

Python uses also docstrings for comments. And I play around with it in R.

normalize <- function(values){
  "comment
   line 2 of comment"
  return(2* values / (max(values) - min(values)) )
}

I am sure I could fix the ESS indentation of comments too, but I like the idea of multiline comments. Are there any downsides with docstrings in GNU R?

È stato utile?

Soluzione

Comments that begin with ## instead of # will be auto-indented in line with the current level of indentation.

j <- function(x) {
                                        # One hash auto-indents to column 40 
    ## Two hashes auto-indent to current level
### Three hashes auto-indent to BOL
    rnorm(x)
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top