Skip to content

Table rda not produced when run inside withr::with_dir #372

Description

@Schiano-NOAA

I was adding a test that has a step to make a table and figure. I want to place these in a folder rather than the wd since I will be placing the report in that folder as well. The figure has no issue producing the rda and figures folder inside of this, but for some reason the table is struggling.

It produces this error:

Error in if (file.exists(fs::path(figures_tables_dir, rda_loc, output_file_name))) { : the condition has length > 1

with this code:

dir.create("species_year1")
year1_dir <- fs::path(getwd(), "species_year1")
  
  # make example table and figure
  withr::with_dir(
    year1_dir, {
      stockplotr::plot_spawning_biomass(
        stockplotr::example_data,
        make_rda = TRUE,
        # figures_dir = x,
        interactive = FALSE
      )
      
      stockplotr::table_index(
        stockplotr::example_data,
        make_rda = TRUE,
        # tables_dir = x,
        interactive = FALSE
      )
    }
  )

I have also tried this:

dir.create("species_year1")
year1_dir <- fs::path(getwd(), "species_year1")
  
  # make example table and figure
  withr::with_dir(
    year1_dir, {      
      stockplotr::table_index(
        stockplotr::example_data,
        make_rda = TRUE,
        # tables_dir = x,
        interactive = FALSE
      )
    }
  )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions