Q:

select columns whose content is having a string (not names but content)

given this data frame (as an example, the real one has more than 100 columns):
df <- data.frame(column_one = 1:2,
                 column_two = 1:2,
                 column_three= 3:4,
                 column_four= 3:4)

I want a new data frame with columns that contained the number 4 this way:
column_three  column_four
3              3
4              4

All I can find on SO is how to select column names containing a given string but that's not my case. The column name is not my issue.
Take into account that I cannot check every column one by one on code regarding the number of columns.

A:

You could do this...
df[,sapply(df,function(x) 4 %in% x)]

  column_three column_four
1            3           3
2            4           4

