What data type I need to put


I have a small question, but annoying me for a while.

I want to use loop to filter all variables that with values. But it seems requires me to put name in a specific way.

Could anyone tell me how I can learn it before I try all the possibilities? Or it comes from the experience that what type of input one need to use according to the situation?

Thanks in advance:)

colnames <- colnames(data)
filter_data <- data
 for (name in colnames){
  filter_data <- filter_data %>%
#  filter(!(is.na(name))) my first try, not work
#  filter(!(is.na(c(name)))) thought it needs a vector, but not work..
  filter(!(is.na(filter_data[name]))) #thought it means specific column, it works
#  filter(!(is.na(filter_data[[name]]))) # it works as well.