I have a dataframe and I want to remove rows with Inf values present in a selected column. I'm looking for a solution using tidyverse as I want to include it into my tidyverse pipes.
Example:
df <- data.frame(a = c(1, 2, 3, NA), b = c(5, Inf, 8, 8), c = c(9, 10, Inf, 11), d = c('a', 'b', 'c', 'd'))
I want to remove rows having Inf values in column c
. The result would be:
df2 <- data.frame(a = c(1, 2, NA), b = c(5, Inf, 8), c = c(9, 10, 11), d = c('a', 'b', 'd'))
I wish there was a function something like drop_inf()
, similar to drop_na()
.
EDIT: The column name is passed as a variable.