xlsx
xlsx copied to clipboard
Variable names with a hyphen
Hello, If a variable name in the first row includes a hyphen '-', this hyphen is imported as a point('.'). e.g.
library(xlsx) data <- read.xlsx("example.xlsx",1) names(data) [1] "VP.Nummer"
But should be [1] "VP-Nummer"
If you need additional information, please feel free to send me a mail, Robert
Hi Robert,
Bit of an old issue I know but thought I would respond!
This is base R behaviour in data.frame()
and not part of the xlsx package.
For example:
> data.frame(`var-name` = 1:5)
var.name
1 1
2 2
3 3
4 4
5 5
You'll find the same behaviour in the base R file reading functions (e.g. read.csv()
).
There are other packages that do it differently (particularly in the tidyverse) but any changes to column name processing in xlsx at this stage would be a huge breaking change.
Cheers, Danny