-3

I am trying to import data from in xls format in R, but it reads the header incorrectly, instead of

X1

R interprets the data as

`X1 `

that makes writing complicated R syntax impossible.

How this issue can be resolved ?

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Idomen
  • 1
  • 3
  • 1
    welcome to SO. you were prompted to write a detailed, reproducible example when you started a question. You've also likely read many SO questions & shld be able to tell good ones from bad ones. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example has info on how to make a gd question. – hrbrmstr Dec 09 '17 at 10:25
  • Having said ^^, why not just change the column names after you read in the xls file? `?colnames` in an R console will show you how to do that. – hrbrmstr Dec 09 '17 at 10:28

1 Answers1

1

One can skip the header record and give your own column names with any number of R packages that read excel data. Here is an example with readxl::read_excel().

library(readxl)
data <- read_excel("./data/anExcelWorksheet.xlsx",
                   col_names=FALSE,
                   skip=1)
Len Greski
  • 10,505
  • 2
  • 22
  • 33