vidya nair vidya nair - 1 month ago 5
R Question

how to increase input file name in a for loop in R

i want to plot 10 different file with names group1.csv to group10.csv, so i have created for loop which run for i = 1 to 10, but how to import these group files in loop?

how to increase file name with 'i' e.g. groupi.csv
file group1 to group10 having three different columns, how to select any two columns as x-axis and y-axis in barplot?

i <- 1
for (i in 1:10)


group <- read.csv("E:/R/r/Dummy Data_globalspace/group'i'.csv")




Use the paste function:

filename <- paste0("E:/R/r/Dummy Data_globalspace/group", i, ".csv")
group    <- read.csv(filename)