Aligning Data frame with missing values

后端 未结 4 1410
盖世英雄少女心
盖世英雄少女心 2020-12-04 00:31

I\'m using a data frame with many NA values. While I\'m able to create a linear model, I am subsequently unable to line the fitted values of the model up with

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 00:56

    If you do not want to change the raw data. Try this way, it's really simple.

    names(fitted.values(model)) are data's rownames of available observations, and we can use this feature to add new column:

    dat[names(fitted.values(model)), "fitted.values"] <- fitted.values(model)
    sum(!is.na(dat[, "fitted.values"]))
    # [1] 2745
    

提交回复
热议问题