NA已添加到数据框中,未显示在输出.csv

将数据集作为df导入到R中。进行一些更改,即进行某些值NA现在尝试将更改后的df写为.csv,但更改未显示在.csv输出中


usnews_colleges1 <- read.csv(file = "/user1/usnews_colleges.csv",header = T,sep = ",")
attach(usnews_colleges1)

#Percentage of faculty with PhDs
w <- which(Pct.of.faculty.with.PhDs > 100)
w
#Change percentages > 100 to NA
Pct.of.faculty.with.PhDs[w] = NA

 Student/Faculty Ratio
x <- which(Student.faculty.ratio > 50)
x
#Change ratios > 50 to NA
Student.faculty.ratio[x] = NA

write.csv(usnews_colleges1,"/uset1/usnews_collegesEdit.csv",row.names = F)


输出文件usnews_collegesEdit.csv应该用NA替换wx所标识的索引中的观察值,即 Pct.of.faculty.with.PhDs[w] = NA应该在output.csv中为观察索引NA输出[82],而不是原始的112

cjh1031 回答:NA已添加到数据框中,未显示在输出.csv

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169285.html

大家都在问