[R] Dealing with data frame column names beginning with a numeric

Patrick Connolly p_connolly at ihug.co.nz
Tue Apr 17 22:03:09 CEST 2007

On Mon, 16-Apr-2007 at 10:12PM +0100, Prof Brian Ripley wrote:

|> On Mon, 16 Apr 2007, Duncan Murdoch wrote:

|> >The name change happens in the conversion to a dataframe, so why not
|> >change the name afterwards?  That is:
|> >
|> >df <- data.frame(mat)
|> >names(df)[3] <- "5T"
|> >boxplot(df, main="blah blah blah")
|> Or use
|> boxplot(as.data.frame(mat))
|> which seems more natural than data.frame(mat, check.names=FALSE) (which 
|> also does the job) or even data.frame(mat).

boxplot(data.frame(mat)) is how it's described in the help, but it
produces the problem that began my discussion (i.e. prepends an "X" to
the name for a dataframe column name).

However, boxplot(as.data.frame(mat)) as suggested by Brian works fine.
So I needed only three keystrokes to get round the problem.

Thank you all.

   ___    Patrick Connolly   
 {~._.~}          		 Great minds discuss ideas    
 _( Y )_  	  	        Middle minds discuss events 
(:_~*~_:) 	       		 Small minds discuss people  
 (_)-(_)  	                           ..... Anon

More information about the R-help mailing list