I fit models like so
groupedTrainingSet = group_by(trainingSet, geo);
models = do(groupedTrainingSet, mod = lm(revenue ~ julian, data=.))
grouptedTestSet = group_by(testSet, geo);
// TODO: apply model back to test set
Where models looks like
geo mod
1 APAC <S3:lm>
2 LATAM <S3:lm>
3 ME <S3:lm>
7 ROW <S3:lm>
4 WE <S3:lm>
5 NA <S3:lm>
I think I should be able to just apply 'do' again but I'm not seeing it...Alternatively I can do something along the lines of
apply(trainingData, fitted =
predict(select(models, geo==geo)$mod, .));
But I'm not sure about the syntax there.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…