I have to two types of datasets that I want to load, process using different functions and then join together.
I have multiple datasets of each of these types, which which names I store in a nested list. I want to apply two different functions (or one function that identifies each dataset in the nested list) to each of the sub-elements in my nested list.
I've tried multiple different variations of lapply, sapply and mapply but haven't succeeded. Instead of showing each thing I've tried, I'll emphasis the intuition of what I'm trying to do below:
list_of_comparisons = list(
list_of_comparison1 = list(
"1. Data/1. X data/Week 22",
"1. Data/1. Y data/Week 22"),
list_of_comparison2 = list(
"1. Data/1. X data/Week 25",
"1. Data/1. Y data/Week 25"
)
)
X = function(First.Element.of.List) {
# Do Something
}
Y = function(Second.Element.of.List) {
# Do Something else
}
final = left_join(X,Y, by = "ID")
I'm searching for a wrapper function or some way which I essentially "loop" over each element, apply function X to the first sub-element, apply function Y to the second sub-element, store the dataframes in a final df, and then move on to the next list. Thus, preferably using lapply since i'll be able to use do.call(rbind) on the final list created by the lapply function.
map_at
ormodify_at
from thepurrr
package – Ben G