Skip to content
Back to formatted view

Raw Message

Message-ID: <8A4B35ED-F0C5-48E2-BD41-B5FCEC53336D@comcast.net>
Date: 2012-11-06T19:43:47Z
From: David Winsemius
Subject: Column names containing ` in R
In-Reply-To: <1352208103052-4648553.post@n4.nabble.com>

On Nov 6, 2012, at 5:21 AM, Raji wrote:

> Hi,
> 
> My data has column names which has ` character. For example , 
> *> names(dataframe)
> [1] "`region"    "farmsize`"  "farmincome" "maincrop"   "claimvalue"*
> 
> If i use these objects in my function, the following error is thrown.
> 
> *lmm<-lm(``region`~farmincome)
> Error: attempt to use zero-length variable name*
> 
> Is there a way, say an escape sequence or something similar in which we can
> give these objects with the colnames to R functions?

The mathod used inread.table is to call make.names()

> make.names(x)
[1] "X.region"   "farmsize." 
[3] "farmincome" "maincrop"  
[5] "claimvalue"

--
David Winsemius, MD
Alameda, CA, USA