You could write a function using quosures to flexibly specify the column name. For example:
library(tidyverse)
fnc = function(data, id_col, filter.length=10) {
id_col = enquo(id_col)
data %>%
filter(str_length(!!id_col) != filter.length)
}
fnc(iris, Species)
fnc(diamonds, cut, 9)
If you also want to always rename the id column to "ID", you could do this:
fnc = function(data, id_col, filter.length=10) {
id_col = enquo(id_col)
data %>%
rename(ID=!!id_col) %>%
filter(str_length(ID) != filter.length)
}