1

Hi I have data in a CSV file which has two date columns(1st and 3rd). When I type in R:

library(tidyverse)
mydata <- read_csv("Dynamic AA.csv", col_types = "DdDd")

It imports the data but both the date columns have only NA values. The data was not imported. Following error is produced:

Warning: 8842 parsing failures.
row        col   expected   actual             file
  1 Date_Debt  date like  06/19/20 'Dynamic AA.csv'
  1 Date_NIFTY date like  06/19/20 'Dynamic AA.csv'
  2 Date_Debt  date like  06/18/20 'Dynamic AA.csv'
  2 Date_NIFTY date like  06/18/20 'Dynamic AA.csv'
  3 Date_Debt  date like  06/17/20 'Dynamic AA.csv'
... .......... .......... ........ ................
See problems(...) for more details.

The date is in the standard R format.

1 Answer 1

1

I think the problem is that the date format is not specified. Something like in the following should work.

mydata <- read_csv("Dynamic AA.csv", col_types = cols(
           Date_Debt  = col_date("%m/%d/%y"),
           scnd_col = col_double(),
           Date_NIFTY   = col_date("%m/%d/%y"),
           forth_col = col_double()))
Sign up to request clarification or add additional context in comments.

3 Comments

Error: Unknown shortcut: %m/%g/%Y
I got this...Error: Unknown shortcut: %m/%d/%y
See the edit col_types = cols(. By the way, make sure to have the correct col names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.