My question might be weird. I am still a beginner in R Programming...looking for efficient ways of coding. I am about to learn how to use the apply-functions in R... So... if I have a list with lists of data frames and want to apply linear models to each of this data frames in the list with less lines as possible... which apply function would this be? Or is it not recommanded to work with lists of lists?
Imagine this example:
iris_split1 <- split(iris[,1:4]*0.5, iris$Species)
iris_split2 <- split(iris[,1:4]*0.85, iris$Species)
iris_split3 <- split(iris, iris$Species)
list_iris <- list(year2017=iris_split1,
year2018 =iris_split2,
year2020 = iris_split3)
# I could do this for only a list of data frames
lm1 <- lapply(iris_split1, function(x) lm(x[,1] ~ x[,2], data = x))
# But I could not found a solution to run it for lists of lists with data frames?
Thanks, Nadine