[R] Suppressing name-wrangling in a data.frame
stephen wisdom
swisdom at operamail.com
Thu Dec 12 21:33:03 CET 2002
Is there a simple way to avoid name-wrangling in a dataframe?
Math operations on a dataframe cause R to correct the names(), for instance from "1" "2" "3" to "X1" "X2" "X3"
A workaround is to as.matrix() the dataframe, perform the math, then re-data.frame() it, but this seems like the long way home
Thanks
Steve Wisdom
> df <- data.frame(matrix(1:15,5),check.names=F)
> df
1 2 3
1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
> df+0
X1 X2 X3
1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
> data.frame(as.matrix(df)+0,check.names=F)
1 2 3
1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
> names(df)
[1] "1" "2" "3"
> names(df+0)
[1] "X1" "X2" "X3"
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 1
minor 6.1
year 2002
month 11
day 01
language R
--
_______________________________________________
Get your free email from http://mymail.operamail.com
Powered by Outblaze
More information about the R-help
mailing list