Delta-Stewardship-Council / swg-21-connectivity

connectivity synthesis subgroup
2 stars 9 forks source link

Pca nutrients #90

Closed ryanpeek closed 2 years ago

ryanpeek commented 2 years ago

a few minor edits and code to make a plot of flow vs. chla

ryanpeek commented 2 years ago

A quick note on the functions that load data...when possible we should load each function (source(f_the_function)) itself, but not run the function too (inside the function file). So for example we want this in our f_function_doing_things.R script:

f_function_doing_things <- function(x){
make_data <- make_awesome_data
write_csv(make_data, "awesome_data.csv")
}

But we don't want this in our script:

f_function_doing_things <- function(x){
make_data <- make_awesome_data
write_csv(make_data, "awesome_data.csv")
}
f_function_doing_things()

We would rather call this function explicitly in whatever script we are using it with:

# load the function
source("f_function_doing_things.R")

# run the function
the_data <- f_function_doing_things()

I know y'all are savvy in this already, so mainly putting this in as documentation/notes for the rationale behind the PR.

catarfish commented 2 years ago

Thanks, yeah I guess I knew that but it's easy to run when it's in there. I usually like running the code immediately rather than in the later code where I call the joint file so the file gets written at that point... guess I haven't quite found the balance of actually using the function in code later for most of the cases of creating files. But I will definitely just run this separately in the future. Thanks for the note!