[R] data frame's column names not the same as in CSV

Don MacQueen macq at llnl.gov
Sat Sep 26 23:17:47 CEST 2009


At 1:58 AM -0400 9/26/09, Derek Foo wrote:
>Hello,
>
>I am trying to read in a csv file with column such as
>"\\LS01\Processor(_Total)\% Processor Time" with the command
>read.csv("file"). However, the column name in the resulted data frame is
>changed to "X..LS01.Processor._Total....Processor.Time".
>
>Strangely,

Not so strange. Data can be anything, but column names are names of 
variables. In R, as in most (all? many?) computer languages, variable 
names have rules they must follow. Yours don't follow R's rules.

See Gabor's response to learn how to tell R to ignore the rules (in 
this particular instance). You will find, however, that later on, 
when you want to use those variables, it will be more difficult to 
use variables whose names do not follow the rules.


>  when I experimented with just reading the csv with the "head"
>flag set to false, the text was read correctly as the same to the raw file.
>I am wondering if anyone has encountered a similar problem. If so, I would
>really appreciate if you can share your insight.
>
>
>Best Regards,
>Derek
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://*stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062




More information about the R-help mailing list