I have few columns which I need to convert to factors
for cols in ['col1','col2']:
  df$cols<-as.factor(as.character(df$cols))
Error
for cols in ['col1','col2']:
Error: unexpected symbol in "for cols"
>   df$cols<-as.factor(as.character(df$cols))
Error in `$<-.data.frame`(`*tmp*`, cols, value = integer(0)) : 
  replacement has 0 rows, data has 942
 
     
    