I try to create a loop that makes join to 5 dataframes like this
c <- list(EC_Pop, EC_GDP, EC_Inflation, ST_Tech_Exp, ST_Res_Jour)
for (i in seq_along(c))
{
if (i < 2)
{
EC_New <- c[i] %>%
left_join(c[i+1], by = c("Country","Year"))
}
else if(i > 1 & i < 4)
{
EC_New <- EC_New %>%
left_join(c[i+1], by = c("Country","Year"))
}
else
{
EC_New
}
}
But I have an error : UseMethod ("left_join") error: No Applicable method for 'left_join' applied to object of class "list"
Can somebody explain the reason? It seems very logical for me the way I wrote it...