我有一个数据框如下:
word count word tf score word probability log values TFxIDF score
1 yemen 380 yemen 1.0000000 0.05393896 2.919902 2.919902
2 strikes 116 strikes 0.3052632 0.01646558 4.106483 1.253558
但是当我运行以下代码时:
p1 <- read.csv("F:/M.Tech/Semester4/Thesis/Code/a1.csv")
x <- nrow(p1)
q <- p1[1,2]
for(i in 1:x) {
p1[i,4]=p1[i,2]/q
}
for(i in 1:x) {
p1[i,5]=p1[i,2]/p
}
for(i in 1:x) {
p1[i,6]= -log(p1[i,5])
}
for(i in 1:x) {
p1[i,7]= p1[i,4]*p1[i,6]
}
我得到了带有额外列的其他数据框:
NA word count word tf score word probability log values TFxIDF score Keyword Probability
1 1 yemen 380 yemen 1.0000000 0.05393896 2.919902 2.919902 NA
2 2 strikes 116 strikes 0.3052632 0.01646558 4.106483 1.253558 0.5
如何删除这些额外的列?