A quick way to do row repeat and col repeat (rep.row, rep.col)
Today I worked on a simulation program which require me to create a matrix by repeating the vector n times (both by row and by col). Even the task is extremely simple and only take 1 line to...
View ArticleA shortcut function for install.packages() and library()
I enjoy trying difference kind of R packages. Since I have more than 1 computers (1 at home, 1 at office and a laptop) it is troublesome to check whether I have installed some new packages for each...
View ArticleGenerating a lag/lead variables
A few days ago, my friend asked me is there any function in R to generate lag/lead variables in a data.frame or did similar thing as _n in stata. He would like to use that to clean-up his dataset in R....
View ArticleA handy concatenation operator
It may be useful for you to define a concatenation operator for characters. Sometimes, I find this is more intuitive and handy than using paste0 or paste. Also, it makes your code look better when you...
View Article