Code efficiency (R) #1554
kubu4
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Well, I took a version of this functional, but messy and redundant code which was ~190 lines of code (snippet):
And, I reconfigured it to this beauty (for very similar data set/calculations), which is only ~60 lines of code and far more legible/manageable:
Also, the code refactoring I've done will now also allow me to easily write all the data frames in the list (using a one-liner with one of the
apply()
functions) to different files, by using the names assigned to each data frame in the list.The key to reconfiguring the code primarily thinking about ways to re-use information, while trying to keep the data manipulations as uniform as possible. This way, I didn't have to re-write variations of the same code to handle different scenarios.
Beta Was this translation helpful? Give feedback.
All reactions