cusisom / cusimano-rclass-project

0 stars 0 forks source link

Code maintenance #5

Open mbutler808 opened 1 year ago

mbutler808 commented 1 year ago

https://github.com/cusisom/cusimano-rclass-project/blob/c20e696417815c67fa0726198b6f7794a1d49f08/Code/Analysis_code/exploratory_analysis.qmd#L13

Hi Danny, it is fine to split your analysis into separate scripts, but you donʻt want to repeat any of your code. That makes it hard to maintain, increasing the chance for error and reducing repeatability. Also you donʻt want to load your packages multiple times. Each line of code should appear only once.

What you can do instead is keep the package loading in the main script, and the code segments in the mini-script. Then in the main script you would have:

require(package)

source("Code_sections/Data_Summary.r")
source("Code_sections/Body_Mass_Analysis.r")
source("Code_sections/Analysis_of_Variancer")

No cut and paste of code! Instead, make your code reusable and just call the code by sourcing it within your script. LMK if this doesnʻt make sense.

cusisom commented 1 year ago

Super interesting. That does make sense. I'll work on it and push it through. Thank you.

cusisom commented 1 year ago

I did a test run of this and kind of love it. Before I implement it though, I realize that this will alter my use of code chunks in the .qmd. Can I set multiple paths for the knitr::read_chunk function?

mbutler808 commented 1 year ago

Can you ask me tomorrow after class? Easier to be looking at it together

mbutler808 commented 1 year ago

Also if you have a change that youʻre still testing, you can create a new branch and push it up to that branch. If you like it, then you can merge it with the main branch