R语言中 找出TXT中的数据后 如何删除?

在整个数据中 data <- read.table("babies.txt", header=TRUE)
找到了(irreg.index <- which(data$smoke == 9)
data.irregular <- data[irreg.index,]
data.irregular #找出错误数据)的错误数据,整行应该删除

请问是要需要回到TXT文件手动删除还是用函数删除?如果不能删除,计算时如何忽略错误行?

data <- read.table("babies.txt", header=TRUE)
(irreg.index <- which(data$smoke == 9) #这个是你要标出的错误数据?
data.irregular <- data[irreg.index,] #这个结果就是错误的行
data.irregular #找出错误数据)
data.right=data[!irreg.index,] #这个结果,data.right 就是没有错误的行
温馨提示:答案为网友推荐,仅供参考
相似回答