-2

When I source the import_data.R script now I get errors that tell me to look at problems(). I enter that function name but there's no return.

Reading ?problems I learned that stop_for_problems(x) should stop the process when a problem occurs, so I added that function to each data file; for example,

library(tidyverse)
library(lubridate)

cor_disc <- read_csv("../data/cor-disc.csv", col_names = TRUE,
                 col_types = list (
                     site_nbr = col_character(),
                     year = col_integer(),
                     mon = col_integer(),
                     day = col_integer(),
                     hr = col_double(),
                     min = col_double(),
                     cfs = col_integer())
                 )
stop_for_problems(cor_disc)

running the command, source('input_data.R') produces this result:

source('import_data.R') Error: 415903 parsing failures In addition: Warning message: One or more parsing issues, see problems() for details

When I run the problems() function nothing is returned:

problems()

What do I read to learn how to identify the problems so I can fix them?

Rich Shepard
  • 109
  • 2
  • 10
  • 1
    Sounds like there are issues when trying to read the csv. But since we don't know what the csv looks like its hard to say... You could read the link about how to create a good [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) and edit your question accordingly. – dario Nov 03 '21 at 20:21
  • What if you add `problems()` to the file you are sourcing? It may be that the `source()` is interfering with the direct access to the global environment which `readr` may be using to actually store the problems. Hard to say without a reproducible example. – MrFlick Nov 03 '21 at 20:26
  • 1
    Have you tried `attr(cor_disc, "problems")` after running `source`? – Allan Cameron Nov 03 '21 at 21:21
  • I can post the script and a URL to the data but I don't know how to do this. It cannot be in a comment; please advise. – Rich Shepard Nov 04 '21 at 13:37

1 Answers1

0

User error: without paying attention to the data type in the last column of most data sets I set them as integers in the read_csv() function. They are doubles and that caused the problems.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Rich Shepard
  • 109
  • 2
  • 10