0

I want to loop through variables and apply that variable to a function

for example how do I loop through a column names and then apply that column name to a function (how do I distinguish a variable i and the character i)

for (i in colnames(uni)){
  print(dim(uni[duplicated(uni$**i**   ,])))
}

I tried paste0 but didn't work

I always have this problem with R so I'd really appreciate help with this

Sareh
  • 1
  • 2
    Use `uni[[i]]` instead of `$i` because `$` will literally check for the column named `i` instead of the value of the `i` looped – akrun Nov 09 '21 at 16:26

0 Answers0