I am not sure if you are looking for this where a
below is the list of all datasets(for your example it can be like for year 1995,1996 and so on)
a<-split(mydata,mydata$cyl)
myprediction<-Map(function(x)predict(lm(mpg~cyl,data=x)),a)
> myprediction
$`4`
Datsun 710 Merc 240D Merc 230 Fiat 128 Honda Civic Toyota Corolla Toyota Corona
26.66364 26.66364 26.66364 26.66364 26.66364 26.66364 26.66364
Fiat X1-9 Porsche 914-2 Lotus Europa Volvo 142E
26.66364 26.66364 26.66364 26.66364
$`6`
Mazda RX4 Mazda RX4 Wag Hornet 4 Drive Valiant Merc 280 Merc 280C Ferrari Dino
19.74286 19.74286 19.74286 19.74286 19.74286 19.74286 19.74286