根据R中的其他变量有条件填充缺失的数据
有人可以通知我填写职业列的NA值的方法吗?我创建一个新的变量来确定申请人是否有效,如果在IS_Working列中相同的观察结果为零,并且将其他NA填充为零,并且将NA值填充。
df <- data.frame (occupation = c("NA","NA","Drivers","Accountants","NA","Drivers","Laborers","Cleaning staff","Drivers","Drivers"),
is_working = c("1","0","1","1","1","1","1","1","1","1")
)
sorry for adding the screenshot, I download data from https://www.kaggle.com/datasets/rikdifos/credit-card-approval-prediction
Can someone inform me about the way to fill those NA values that the occupation column has? I create a new variable to determine whether an applicant is working or not and I want to fill NA values as zero if the same observation is zero in is_working column and left the others NA.
df <- data.frame (occupation = c("NA","NA","Drivers","Accountants","NA","Drivers","Laborers","Cleaning staff","Drivers","Drivers"),
is_working = c("1","0","1","1","1","1","1","1","1","1")
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)