apply() allows you to select whether rows or columns with MARGIN=1 or MARGIN=2, respectively.
But apply only works on matrices.
For example, I have three rows of header information and 3 columns of descriptive information. I need to combine these into row names and row names and column names, respectively. So I can't easily use read.table() and skip the first 3 rows, and then delete the first 3 columns to get my matrix right away.
This doesn't work on data frames, just matrices
rownames(df)<-apply(df[,1:3], MARGIN=1,FUN=function(x){paste(x,sep=".")})