如何使用R中同一列中的其他值填充数据框中数据的缺失值

时间:2019-04-21 14:06:16

标签: r

我有一个看起来像

的数据框
const JwtStrategy = require("passport-jwt").Strategy;
const ExtractJwt = require("passport-jwt").ExtractJwt;
const mongoose = require("mongoose");
const Student = mongoose.model("students");
const Admin = mongoose.model("admins");
const keys = require("../config/keys");
const opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
opts.secretOrKey = keys.secretOrKey;

module.exports = passport => {
  passport.use(
    new JwtStrategy(opts, (jwt_payload, done) => {

      Student.findById(jwt_payload.id).then(student => {
        if (!student) {
          Admin.findOne(jwt_payload.id).then(admin => {
            if (!admin) {
              return done(null, false);
            }
            return done(null, admin);
          });
        }
        return done(null, student);
      });
    })
  );
};


现在,我想用相同的Name Value Car1 Station Car1 NA Car1 NA Car1 Station Car2 Hatchback Car2 NA 变量的非NA值填充NA列中的Value值。因此,结果数据框应类似于

Name

有人知道如何做到这一点而不遍历整个数据帧吗?

0 个答案:

没有答案