I have a list consisting of a total of 24 dataframes of various row numbers. Some of these rows have empty values, i.e. neither NA or NULL, just "". The number of such rows varies between the dataframes, but I want to remove these rows.
Sample dataframe, but this is pretty much how all the dataframes in the list looks like, with lots of empty values, and a few values I want to keep.
>df <- data.frame(c("","","","A","","B","","","C"))
colnames(df) <- "sn"
> df
sn
1
2
3
4 A
5
6 B
7
8
9 C
I've tried to delete these rows directly, according to this page or this page, adding NA's to the empty rows from this page, before omitting those rows, and even test[complete.cases(df), ]
from here. None of this seems to work, as nothing happens to neither of the dataframes within the list. I've tried for just one of the dataframes within the list as well, like the sample one shown here, but just with more rows, but still no change.
From various pages here on Stack Overflow, these are a few of the codes I've tried to solve the
1) df <- lapply(df, function(x) sapply(df, nrow)>0)
2) lapply(df, function(x){ df[rowSums(is.na(df)) != ncol(df),]})
3) df[!apply(df == "", 1, all),]
4) df[rowSums(df=="")!=ncol(df), ]
5) df[apply(df, 1, function(x) any(x != '')), ]
6a) df[df==""]<-NA
6b) df[complete.cases(df),]
All of these attempts have unfortunately done nothing with the dataframe, leaving it identical as listed above.
Any suggestions? Thank you very much in advance!