[Solved] Linear regresion of rectangular table against one set of values


One way is to spread your data table using Country.Name as key:

dat.spread <- dat %>% spread(key="Country.Name", value="inflation")
dat.spread %>% str
'data.frame':   50 obs. of  31 variables:
 $ year              : chr  "1967" "1968" "1969" "1970" ...
 $ Albania           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Armenia           : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Brazil            : num  NA NA NA NA NA NA NA NA NA NA ...
 [...]

But that forces you to transform the data which may seem undesirable. Afterwards, you can simply use cbind to do the linear regression against all countries:

lm(cbind(Armenia, Brazil, Colombia, etc...) ~ Albania, data = dat.spread)

solved Linear regresion of rectangular table against one set of values