pfmc-assessments / lingcod

https://pfmc-assessments.github.io/lingcod/
2 stars 2 forks source link

problem reading models/README.md #188

Closed iantaylor-NOAA closed 2 years ago

iantaylor-NOAA commented 2 years ago

@kellijohnson-NOAA, can you help me with this error when running get_mod()

Error: '# table' does not exist in current working directory ('c:/ss/Lingcod/Lingcod_2021').

which I've traced to this call to readr::read_delim() in get_mdtable(): https://github.com/iantaylor-NOAA/Lingcod_2021/blob/main/R/get_mdtable.R#L20-L26. Indeed, this command produces the same error: get_mdtable(file.path("models", "README.md"), "# table"). The input to read_delim() is a vector of strings that includes "# table" as the first value, but maybe the function has changed in some way that makes this no longer work as it did previously.

I'm using a fresh instance of R with nothing loaded except the lingcod package.

kellijohnson-NOAA commented 2 years ago

This has to do with changes to readr::read_delim which is now in a new major version. The function works if you override settings your options.

options("readr.edition" = 1)
get_mdtable(file.path("models","README.md"), "# table")

I recommend changing the start of get_mdtable() to store current options, set readr.edition option, run everything, restore old option, and exit from the function.

iantaylor-NOAA commented 2 years ago

That did the trick, thank you @kellijohnson-NOAA.