r - Variable assignment during re-coding loop -
i importing survey data csv file in r, , want use for-loop reassign periods in cells "na". 1 survey item, have this: survey$q1a <- recode(survey$q1a, "'.'=na") # csv column survey$q1a <- as.numeric(as.character(survey$q1a)) where q1a column title in csv file, , refers question 1, part (i have 137 columns). so, in order make for-loop, need able this: for (n in 1:31){ survey$qna <- recode(survey$qna, "'.'=na") # csv column n survey$qna <- as.numeric(as.character(survey$qna)) } 31 items have part a, means need survey$q1a survey$q31a . sake of simplicity, best keep columns in qna format (ironically). have never used r, have experience python , c, , know use % %s operators in languages achieve similar goals. is there way in r without changing how variable/column labeling system?