Is there a way in R to find out if a value is convertible to numeric or not? I usually do type.convert(as.is=T)
to convert my columns into numeric and perform mathematical functions. But my current table has some values that cannot be converted. I would like to pull those non-NA rows that do not include numeric convertible characters in columns that end with "a".
DATA
df <- data.frame(names=c("Shawn", "James", "Caleb", "David"), a_a=c("1",NA,"bad","1"),a_b=c("1",NA,"1","good"))
names a_a a_b 1 Shawn 1 1 2 James <NA> <NA> 3 Caleb bad 1 4 David 1 good
df %>%
filter_at(vars(ends_with("a")), any_vars(!is.na(.) & class(.) != "character")
DESIRED OUTPUT
names a_a a_b Caleb bad 1