For loop for columns in R

I think it would be helpful to know what the structure of the data is. Is x a matrix, a data.frame, a tibble, a list, or what? The best option would be to create a reproducible example: FAQ: What's a reproducible example (`reprex`) and how do I do one? and it would make it a bit easier for us to help