Good variable names are:
a) short / easy to type,
b) easy to remember,
c) understandable / communicative.
Am I forgetting anything? Consistency is something to look for. The way I would put it is that consistent naming conventions contribute to the qualities above. Consistency contributes to (b) ease of recall and (c) understandability, though other factors are often more important. There is a clear tradeoff between (a) name length / ease of typing (e.g. all lowercase) and (c) understandability.
I'm investing a fair bit of thought in these issues because thousands of people are using the data and I hope many will use my code to prepare the data and facilitate some types of analysis. The data, from the Longitudinal Study of Adolescent Health, is broken down into multiple datasets. My first step was to take the 227 variables in the most commonly used dataset, recode them, give them more meaningful names. Original variable names are things like "aid", "s1", "s2", which I renamed "aid2", "age", and "male.is". There are thousands of other variables in the other datasets which may be merged depending on what the researcher's goals are.
As long as I'm renaming variables, I want to make them as useful as possible. Here are some of the issues I've considered. So far, I have only used lower-case and avoided using any dashes or underscores, and I've only used periods for one very specific purpose. This has the virtue of simplicity and consistency, and causes no problems for most variables. But as things get more complex I'm tempted to break my consistency. Take, for example, my variable "talkprobmsum", it would be easier to read as "talkProbMSum" or better still "talk.prob.m.sum", but if I'm going to use capital letters or periods to separate words then shouldn't I do it for all variables?
Some variables are recorded at more than one time, e.g. the race variables so I appended .is or .ih to indicate whether they come from the in-school or in-home questionnaire. But there are surely some repeats I'm not aware of yet, would it be better to append a reference to the dataset to the name of every variable?
I need to group-center and standardize a lot of variables, the way I've done that is by appending .zms meaning z-score by male and by school.
Any general or specific thoughts or resources are greatly appreciated. See this repository for some of my code, and descriptive statistics with a list of variable names. I briefly described the reason for sharing this code here, and it was publicized a bit here, but these last two links aren't really relevant to the issue of variable naming conventions. Added: I edited this lightly, mostly just moving a paragraph, to try to avoid some of the confusion evident in the comments. Thanks for thoughts!
Variable and function names should be lowercase. Use an underscore (_) to separate words within a name.
Don't use underscores ( _ ) or hyphens ( - ) in identifiers. Identifiers should be named according to the following conventions. The preferred form for variable names is all lower case letters and words separated with dots (variable.name), but variableName is also accepted; function names have initial capital letters and no dots (FunctionName); constants are named like functions but with an initial k.