There are places in the demo scripts that inherit things from Mx that are not necessary: like the fact that Mx couldn't read files with a labels line..
So in , we see:
data(twinData) twinVars <- c('fam','age','zyg','part','wt1','wt2','ht1','ht2','htwt1','htwt2','bmi1','bmi2')
Much easier to say
data(twinData) twinVars = names(twinData) # maybe with a comment so people know what is going on # 'fam','age','zyg','part','wt1','wt2','ht1','ht2','htwt1','htwt2','bmi1','bmi2'
Also enhances script re-use, avoids maintainance hassles and error.
Agreed. Good practice to add the comment too.
In my R code I always have a "variables block" so that I can go back and see what I've done. It helps when I go back to code from 1992 (yes, I do have S code from 1992).
I learned to code in assembly and C, so declaration blocks seem friendly to me. I put this in a comment in R since there is no need for a declaration block in R.
I start all of my R scripts with a comment block that looks something like this. I use a Textmate template that spits out the block so all I need to do is fill it in. Note that I name my scripts with an included date in reverse order so that file names also sort themselves by date when they are sorted alphabetically.
I find these to be useful programming habits that have helped me over a span of decades.