Search code examples
rexcelnumbersrexcel

Numerical column in Excel gets converted as logical


When I try to import data into R studio from Excel, the number columns are getting imported as Logical in R.

Is there a way to import these columns as a number into R? The column in Excel has been formatted to number.

I am using read_excel to import the file.

The spreadsheet I am trying to import has 80 columns.


Solution

  • use col_types and explicitly specify the column types.

    read_excel(path, sheet = 1, col_names = TRUE, col_types = c("text","numeric","date"), na = "", skip = 0)
    

    https://www.rdocumentation.org/packages/readxl/versions/0.1.1/topics/read_excel