I have a number of .csv files which are called "1_a.csv", "2_a.csv", "3_a.csv", "4_a.csv", and so on. Within each .csv file is a column called "participant", which currently has the participant number. For example, in "1_a.csv" under "participant" is 1, in "2_a.csv" under "participant" is 2.
What I would like to do is edit the column "participant" in each of these .csv files so that it also has the "_a", so in "1_a.csv" under "participant" is 1_a, in "2_a.csv" under "participant" is 2_a, and so on. However, I haven't been able to figure this out.
files <- list.files(path = 'data/', pattern = '*.csv', full.names = TRUE) # load data
for (filename in files) {
df = read.csv(filename)
df$participant = df$participant + "_a"
}
Can anyone help?