I have a R code to filter the data frame values - age and no. of cars. I want to remove the floating values in car column if there are any. For example:
Age Cars
29 2
27 3
18 2.3
31 4
17 2
20 -1
Here I want to remove the records whose age is <18, cars >=0 and also records having 2.3 cars (floating) value in R.
bikers_inconsistent <- function(n){
# To check age of the rider >=18 and no. of cars >=0
x <- n[n$age>=18 & n$cars>=0 ,]
return(x)
}
I have written the code to retrieve cars >=0 and age>=18. But struggling to filter the data which have floating values.
Please help as I'm new to R