![]() ![]() ![]() Results_df <- rbind(results_df, c(outcome_list]$V2, X] <- lm(outcome_list]$V1 ~ mtcars$mpg + mtcars$cyl) Results_df <- as.ame(cbind(dataframe_id = c(0), intercept = c(0), # Below this line is my current solution with a for loop that works fine Mtcars <- mtcars #I will use the explanatory variables from here Outcome_list <- list(as.ame(cbind(rnorm(32), dataframe_id = c(1))),Īs.ame(cbind(rnorm(32), dataframe_id = c(2))),Īs.ame(cbind(rnorm(32), dataframe_id = c(3)))) # This represents my list of 198135 dataframes ![]() Here's some example code of my problem in a smaller scale: library(tidyverse) The problem is that I don't know how to transform my for loop in a foreach loop for taking advantage of parallel computing. I know that R is using less than 20% of my 8-core CPU, and I would like to use it all. I wrote a functional "for loop" that does the task properly, but it takes more than 35 hours for finishing it. I have to store all beta and p values for each predictive variable in the models in a dataframe, and also their goodness-of-fit measures. I need to generate linear models for 198135 outcome variables contained in dataframes within a list object. I'm dealing with a problem that requires parallel computing for getting faster results than with a classic "for loop". ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |