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
Open
Allow data.frame input to load_[mix/source/discr]_data and add option print/save controls to isospace plot_data #408hannahrempel wants to merge 4 commits into
hannahrempel wants to merge 4 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.