1

This question might sound silly, anyway, I have a csv file with column names like this: gauge_(1), gauge_(2) , etc. and when I load it using read.csv() the names change to gauge_.1., gauge_.2., etc.

I tried using the quote argument but couldn't get any good result.

What should I do to keep the names without change? I mean whitout the ( ) characters being changed to dots?

Thank you!

noriega
  • 447
  • 1
  • 9
  • 23
  • 5
    `read.csv(..., check.names = FALSE)` will allow you to keep the original column names. But things like `df$gauge_(1)` won't work, that's why R changes them. I would recommend either letting R change them or changing them yourself to something like `gauge_1`. – Marius May 23 '17 at 03:17
  • @Marius, post as answer (if you can't find a duplicate, which would be better)? – Ben Bolker May 23 '17 at 03:25
  • Like @Marius mentioned, you can't have names with parenthesis in them. Parenthesis are reserved for functions and having them in the names could really mess things up. You could try the `readr` package which has the `read_csv()` function. It might surround the column names with forward ticks. So the names will become df$`gauge_(1)'. (Note the last ' should be a back tick but this changes the formatting in stack overflow) – Jeff Parker May 23 '17 at 05:03

0 Answers0