Skip to content →

2018/02/07: Variable naming

I recently realised that I am sometimes quite inconsistent when it comes to naming variables. I decided to stipulate a variable naming convention that I can stick to. This convention should be useable in the three major languages I use (R, Matlab, C#). That means I can’t for instance use dots within a name because it would only work in R.  I will keep an updated version here.

I hereby stipulate the following rules to name variables:

  • Variable names should be informative. Example: rt for reaction time.
  • They should be short. Therefore I will use capitalisation to separate the variable name instead of for instance an underscore. Example: dataMean.
  • The variable should start with a lower case later.
  • If the variable is in some way nested, the name should indicate that by a decreasing hierarchy. Example: dataSub1Mean.
  • I will use the following abbreviations for singular and plural form:
    • acc = accuracy
    • err = error
    • rt = reaction time
    • con = condition
    • conf = confidence
    • comb = combination/combined
    • obj = object
    • num = number
    • iter = iteration
    • disp = display
    • subNo = subject number
    • sub = subject
    • pos = position
    • len = length
    • dim = dimension
    • rect = rectangle
    • resp = response
    • img = image
    • tex = texture
    • str = string
    • logi = logistic


These are variables I used and then changed according to convention:
numberObjects -> numObj             
sub_SS_foils    -> foilSsSub

Published in meta


Leave a Reply

Your email address will not be published. Required fields are marked *