Skip to content

Allow data.frame input to load_[mix/source/discr]_data and add option print/save controls to isospace plot_data #408

Open
hannahrempel wants to merge 4 commits into
brianstock:masterfrom
hannahrempel:master
Open

Allow data.frame input to load_[mix/source/discr]_data and add option print/save controls to isospace plot_data #408
hannahrempel wants to merge 4 commits into
brianstock:masterfrom
hannahrempel:master

Conversation

@hannahrempel

Copy link
Copy Markdown

I made two related sets of modifications to improve usability when running many MixSIAR models programmatically.

1. Allow data.frame input to load_mix_data(), load_source_data(), and load_discr_data()

I lightly modified the load_[mix/source/discr]_data functions to accept data.frame objects in addition to file paths to .csv files.

Reason: This allows users to format MixSIAR input data within R scripts, rather than writing multiple intermediate .csv files and reading those into the models. This is particularly helpful when running many models (e.g., multiple consumer species with species-specific informative priors–necessitating an individual model per species), where the current workflow would require generating dozens of separate .csv files (e.g., 10 species × mix/source/discrimination = 30 files). Accepting data.frame input makes large, scripted workflows more efficient and user-friendly.

2. Add optional control over saving, printing, and returning isospace plots in plot_data()

I modified plot_data() to optionally:

  • save plots to file,
  • print plots to the active graphics device, and/or
  • return ggplot objects for modification.

Reason: This provides users with more control over plotting behavior and helps prevent graphics device overload—particularly in R Markdown or batch workflows—when running multiple models or using many tracers. For example, models with six EAA tracers produce 15 pairwise isospace plots per model; when run in loops/across multiple species, this can easily trigger “too many open devices” errors. Separating plot saving from plot display improves stability without changing default behavior.

Updating function to allow data.frame input in addition to .csv files
Updating function to allow dataframe input in addition to .csv
Updating to allow for dataframe input in addition to .csv
Optionally saves, displays, and/or returns ggplot objects. This prevents graphics devices from being overloaded—triggering “too many open devices” errors—when running models with many tracers, particularly in R Markdown and batch workflows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant