Here is a data frame:
df <- data.frame('a' = c('NULL',1,4,5), 'b' = c(5,6,3,'NULL'), 'c' = c(9,'NULL',9,3))
Output:
a b c
1 NULL 5 9
2 1 6 NULL
3 4 3 9
4 5 NULL 3
What I am trying to do remove all cells with a null value. One method is like this:
df2 <- data.frame('a' = subset(df, !(a == 'NULL'))$a,
'b' = subset(df, !(b == 'NULL'))$b,
'c' = subset(df, !(c == 'NULL'))$c)
Output:
a b c
1 1 5 9
2 4 6 9
3 5 3 3
However, this is inefficient. Is there away to remove any cell with a null value?