Understanding Date Type Handling When Importing CSV Data into R

Asked 2 years ago, Updated 2 years ago, 313 views

Problems

When reading.csv with R, I want to convert the date type column to a numeric type for import, and even if I format the column numerically in the spreadsheet from which the csv is based, if I import it into R, it will be treated as a character type (chr).

Tried

  • Insert a new column on Spreadsheet and try to value a column of date type converted to a number
  • If you try as.numeric in R for columns that are strings (data with numeric dates), all of them will become NA

What would you like to know

What should be done in advance on Spreadsheet to make the column numeric when CSV is imported?

r

2022-09-30 21:51

1 Answers

You can use the read_csv package.

#Read data
data<-read_csv('filepath.csv')

# Checking Column Types
str(data)


2022-09-30 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.