I have a csv that I would like to import into R as a data.frame. This csv has headers such as USD.ZeroCouponBondPrice(1m)
and USD-EQ-SP500
that I can't change. When I try to import it into R, however, R's read.csv
function overwrites the characters ()-
as .
Although I wasn't able to find a way to fix this in the function documentation, this line of code worked:
colnames(df)<-c('USD.ZeroCouponBondPrice(1m)', 'USD-EQ-SP500')
so those characters are legal in data.frame
column names. Overwriting all of the column names is annoying and fragile as there are over 20 of them and it is not unthinkable for them to change. Is there a way to prevent read.csv
from replacing those characters, or an alternative function to use?
Tibbles
. WithTibbles
you can use crazy name for the names of variables. – Kunstlied