back with another one
i have several dataframes and am trying to remove (i) rows with specific strings in one column and (ii) rows with na's in that same column. I've put together code of the form below
for (i in c(df1, df2, df3)){
i <- i[!grepl("badString", i["Column"]),]
i <- i[!is.na(i["Column"], ]
}
But I keep getting this error
Error in i[!grepl("badString", i["Column"]), ] :
incorrect number of dimensions
I previously tried to specify the column using i$Column
, but also got this error message
Error: $ operator is invalid for atomic vectors
I've also tried using double columns (replacing i["Column"]
with i[["Column"]]
), but no dice with this strategy as well
Thank you all again for saving my ass every day!!!
question from:
https://stackoverflow.com/questions/65931018/deleting-rows-from-data-frames-within-for-loop 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…