xlsx icon indicating copy to clipboard operation
xlsx copied to clipboard

Variable names with a hyphen

Open statistik-verstaendlich opened this issue 8 years ago • 1 comments

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

example.xlsx

statistik-verstaendlich avatar Jun 18 '16 15:06 statistik-verstaendlich

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

gorcha avatar Mar 17 '19 16:03 gorcha