I can't vouch for the validity of your approach from a statistical standpoint, but, to test my code you only need to manually filter by any country and perform a linear regression, the results are exactly the same.

```
library(gapminder)
library(tidyverse)
explic<-list("year","gdpPercap")
gapminder %>%
pivot_longer(cols = c(-country, -lifeExp, -continent),
names_to = "independent_var",
values_to = "value") %>%
filter(independent_var %in% explic) %>%
group_nest(country, independent_var) %>%
mutate(model = map(data, ~broom::glance(lm(lifeExp~value, data=.x)))) %>%
select(-data) %>%
unnest(model)
#> # A tibble: 284 × 14
#> country independent_var r.squared adj.r.squared sigma statistic p.value
#> <fct> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Afghanistan gdpPercap 0.00226 -0.0975 5.34 0.0227 8.83e- 1
#> 2 Afghanistan year 0.948 0.942 1.22 181. 9.84e- 8
#> 3 Albania gdpPercap 0.701 0.671 3.63 23.4 6.82e- 4
#> 4 Albania year 0.911 0.902 1.98 102. 1.46e- 6
#> 5 Algeria gdpPercap 0.818 0.800 4.63 45.0 5.33e- 5
#> 6 Algeria year 0.985 0.984 1.32 662. 1.81e-10
#> 7 Angola gdpPercap 0.0906 -0.000286 4.01 0.997 3.42e- 1
#> 8 Angola year 0.888 0.877 1.41 79.1 4.59e- 6
#> 9 Argentina gdpPercap 0.692 0.661 2.44 22.4 7.97e- 4
#> 10 Argentina year 0.996 0.995 0.292 2246. 4.22e-13
#> # … with 274 more rows, and 7 more variables: df <dbl>, logLik <dbl>,
#> # AIC <dbl>, BIC <dbl>, deviance <dbl>, df.residual <int>, nobs <int>
gapminder %>%
filter(country == "Afghanistan") %>%
lm(formula = "lifeExp~gdpPercap", data = .) %>%
broom::glance()
#> # A tibble: 1 × 12
#> r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.00226 -0.0975 5.34 0.0227 0.883 1 -36.0 78.1 79.5
#> # … with 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>
```

^{Created on 2022-07-28 by the reprex package (v2.0.1)}