My C-oriented Stan collaborators have convinced me to use underscore (_) rather than dot (.) as much as possible in expressions in R. For example, I can name a variable n_years rather than n.years. This is fine. But I’m getting annoyed because I need to press the shift key every time I type the underscore.
What do people do about this? I know that it’s easy enough to reassign keys (I could, for example, assign underscore to backslash, which I never use). I’m just wondering what C programmers actually do. Do they reassign the key or do they just get used to pressing Shift?
P.S. In comments, Ben Hyde points to Google’s R style guide, which recommends that variable names use dots, not underscore or camel case, for variable names (for example, “avg.clicks” rather than “avg_Clicks” or “avgClicks”). I think they’re recommending this to be consistent with R coding conventions.
I am switching to underscores in R variable names to be consistent with C. Otherwise we were running into difficulties because Stan, following C, does not allow dots in variable names. I don’t want to have a variable that’s called sd.y in R and sd_y in Stan. Much easier to have the same name in both. We don’t want to be changing Stan’s rules (too much of a mess given that Stan is written in C++) so I have to change my R conventions. Then once I switch to underscores for variables that go into Stan models, I’m inclined to be consistent and use underscores throughout.