I'm a new programmer and I'm stuck with the creation of a function or loop to avoid repetition of the lines.
Here is part of my code:
# Importing dataframes
R1 <- read.table("C:/Users/Data1.txt", header = TRUE)
R2 <- read.table("C:/Users/Data2.txt", header = TRUE)
R3 <- read.table("C:/Users/Data3.txt", header = TRUE)
# Taking only the colunms that I need from each dataframe
R1_dados <- R1[,c(1,8,11,14,24)]
R2_dados <- R2[,c(1,8,11,14,24)]
R3_dados <- R3[,c(1,8,11,14,24)]
# Adding some colunms
R1_dados$E <- c(0,100,200,300,400,500,600)
R2_dados$E <- c(0,100,200,300,400,500,600)
R3_dados$E <- c(0,100,200,300,400,500,600)
# Doing some math between columns from each dataframe
R1_dados$rETR = R1_dados$fvfm*R1_dados$E
R2_dados$rETR = R2_dados$fvfm*R2_dados$E
R3_dados$rETR = R3_dados$fvfm*R3_dados$E
# and so on...
I was wondering if I can create an index of the replicas (R1, R2, and R3)
I'll be grateful if someone helps me. Thanks!