[R] no _?

Jason Turner jasont at indigoindustrial.co.nz
Sat Dec 8 05:52:43 CET 2001


On Fri, Dec 07, 2001 at 09:53:28PM -0800, Jeff D. Hamann wrote:
> I see the uderscore "_" is not allowed in R. This make R a real drag when
> trying to use with SQL packages and c code. 

A work-around I use is make.names(), which converts "illegal" variable
names to legal ones in R.

names(some.data.object)<-make.names(names(some.data.object))

if you've somehow managed to get an illegal name in there.

e.g.
> zz<-data.frame(c(1,2,3),c(4,5,6))
> zz
  c.1..2..3. c.4..5..6.
1          1          4
2          2          5
3          3          6
> names(zz)<-c("age","number_of_feet")
> 
> zz
  age number_of_feet
1   1              4
2   2              5
3   3              6
> names(zz)<-make.names(names(zz))
> zz
  age number.of.feet
1   1              4
2   2              5
3   3              6
> 

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list