Suppose I use the xlsx package to write a dataframe from r to excel. And suppose I have a dataframe with a column title that includes a question mark (code below):
library(xlsx)
rm(list = ls())
fpath <- "whatever filepath"
#My df
df <- data.frame("Questions?" = c("bla", "bla bla"), "123Numbers"= c(1,2))
#Now output
wb <- createWorkbook()
sh <- createSheet(wb, sheetName = "Bla")
addDataFrame(df, sh)
saveWorkbook(wb, paste0(fpath,".xlsx"))
When I open the excel output file, I get the following: Result
- Why does the question mark show up as a period in the Questions column title?
- Why is there a random "X" character in front of the 123Numbers column title?
Of course, if there is an easy fix to this that I am missing, please advise. Thanks!