This seems to be an efficient way to list vars with column number:
cbind(names(df))
Output:
[,1] [1,] "A" [2,] "B" [3,] "C"
Sometimes I like to copy position variables to my code, so I use this function:
varnums<- function(x) {w=as.data.frame(c(1:length(colnames(x))), paste0('# ',colnames(x))) names(w)= c("# Var/Pos") w} varnums(df)
Output:
# Var/Pos
Dan Tarr Jun 01 '18 at 20:53 2018-06-01 20:53
source share