I am importing a csv of stock data into R, with column names of stock ticker which starts with number and containing space inside, e.g. \"5560 JP\". After reading into R, th
When you use write.csv or write.table to save your data to a CSV file, you can set the column names to whatever you like by setting the col.names
argument.
But that assumes you have the column names to available. Once you've read in the data and R has converted the names, you've lost that information. To get around this, you can suppress the conversion to get the column names:
df <- read.csv("mydata.csv", check.names=FALSE)
orig.cols <- colnames(df)
colnames(df) <- make.names(colnames(df))
[your original code]
write.csv(df, col.names=orig.cols)