-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
OK -- not quite accurate, since using map or apply is just a for loop under the hood.
But, the point is that for loops that have significant logic in them are difficult to debug.
What is better is to take a page from the book of functional programming and write the
logic which executes on any given iteration of the loop into a function (or a number of functions)
and then apply that function(s) over the input list.
So, plot_metrics, rather than this:
for (i in 1:length(metric_dfs_by_net[[1]])) {
metric_dfs[[i]] <- do.call(cbind, lapply(unname(metric_dfs_by_net), "[[", i))
}
# assemble y-axis labels
to_plot <- c(sum, pe
... # it goes on for many lines ....write the logic inside of that loop into a function
Metadata
Metadata
Assignees
Labels
No labels