Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 202012

Why does a question mark in a dataframe column title show as a period when outputting from r to an excel sheet (using xlsx package)?

$
0
0

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

  1. Why does the question mark show up as a period in the Questions column title?
  2. 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!


Viewing all articles
Browse latest Browse all 202012

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>