<snip>

(Ted Harding) wrote:
> Are you sure the name really is "CPI/RPI"? In setting
> yp my example, I read in a CSV file "temp.csv":
> 
> A,B/C
> 1,2
> 3,4
> 5,6
> 
> with
> 
> D<-read.csv("temp.csv")
> 
> and got:
> 
>> D
>   A B.C
> 1 1   2
> 2 3   4
> 3 5   6
> 
> so read.csv() had changed the name from "B/C" to "B.C".
> I had to do
> 
> names(D)<-c("A","B/C")
> 
> to bring it back to the example above.


Ted,

The read.table() family has an argument 'check.names' which is TRUE by
default. This calls make.names() to check the syntactical validity of
the column names:

> make.names("B/C")
[1] "B.C"

See ?make.names for more detail.

If you had used:

  D <- read.csv("temp.csv", check.names = FALSE)

the column names would have been unaltered.

For example, reading your data from the clipboard:

> read.csv("clipboard")
  A B.C
1 1   2
2 3   4
3 5   6

> read.csv("clipboard", check.names = FALSE)
  A B/C
1 1   2
2 3   4
3 5   6

Regards,

Marc

______________________________________________
R-help@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.

Reply via email to