How to tabulate columns by index number instead of column names

Hi,
I have a dataset with very long names for some variables, and I want to tabulate them. So I am wondering if it is possible to tabulate them using the column index instead of name for convenience.

Please let me know.

Thank you.

1 Like

I'd make a copy of the data frame and rename the columns:

data2 <- data1
colnames(data2) <- seq(1,ncol(data2)) 

Then you can do your tabulation code on data2:

# >... code to do table stuff...
rm(data2) # tidy up when you're done!
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.