Numbers as column names of data frames

Nathaniel Saxe picture Nathaniel Saxe · Aug 6, 2010 · Viewed 30.8k times · Source

Is there a reason why R won't allow me to have a number as the column name of my dataframe?

Also noticed that if i do data.frame(XX) it adds an X to all the column headers that have numbers at the front.

Answer

Marek picture Marek · Aug 6, 2010

Works for me

data.frame(`1`=rnorm(3), `2`=head(letters,3), check.names=FALSE)
#        1 2
# 1 0.5019 a
# 2 1.1148 b
# 3 0.4787 c