0

In R, I want to name a variable something equivalent to AUC/D, as the variable is defined as the ratio between AUC and D. I obviously want to, if possible, to avoid / and %. What would be a short, legal and easy to read division-operator to use in variable names?

Are there manuals of recommended variable namings for R?

Soren Havelund Welling
  • 1,823
  • 1
  • 16
  • 23
  • 1
    Not sure if there's any guideline for such naming conventions. Personally, I tend to use the "[snake case](https://en.wikipedia.org/wiki/Snake_case)", and in this particular situation one might consider `AUC_over_D` as a possible name. – RHertel Mar 18 '16 at 09:26
  • According to [google](https://google.github.io/styleguide/Rguide.xml) my suggestion is BAD. They suggest the camelCase or a separation by a dot. I disagree with that last option, as I think it is prone to lead to confusion with the syntax that is used in Object Oriented Programming languages such as Java or C++, where the dot operator has a very specific meaning. – RHertel Mar 18 '16 at 09:46
  • 1
    I like `per` as a name infix to indicate division. I prefer all lowercase names, so I would call it `auc_per_d`. – Gregor Thomas Mar 18 '16 at 16:38

2 Answers2

0

I think there is no consensus on that kind of issue. The most important thing is to be consistent across your codes. For example, I often use variables that represent probabilities and percentages. I name name the variables that represent probabilities as follow: Pr_name where Pr is short for probabilities. For percentages I use Pct_name where Pct is for percentage.

In case of a ratio, you could use rat_var1_var2 for instance.

Aurelien_J
  • 13
  • 2
0

I started using "s" for "split". "d" is used for other things (such as differential), and I use "p" for "point" (as in pi = 3p14159...), but "s" seems fairly open. So, for example, the variable name I would use for x/3 would be xs3, or xS3, or x_s3, or x_s_3, depending on the other conventions I was using in the code. Using "r" instead for "ratio" might be good, but "5 ratio 3" makes me think of the symbol "5:3", whereas "5 split (into) 3" makes me think only of 5/3.