Extra columns appearing while running loop in R -
i have data frame following:
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 but when run following code:
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] } i other data frame columns as:
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 how can remove these columns coming?
Comments
Post a Comment