Reputation: 3821
I'm using the write.table()
method to write a matrix into a text file. My matrix has row and column names. I noticed that R messes up that names.
First of all names that start with a digit are wrote using X
as prefix. For example 1005_at
will become X1005_at
.
Second characters as -
and /
are substituted with a dot .
.
Why is this happening? Is there a way to avoid this crazy issue?
Upvotes: 1
Views: 718
Reputation: 25608
make.names
is used to convert names to syntactically valid ones. Check out this small example:
> make.names(c(".1 - / q", "if", "0", "NA"))
[1] "X.1.....q" "if." "X0" "NA."
The documentation says:
A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. <...> The character "X" is prepended if necessary. All invalid characters are translated to "."
Upvotes: 1