I need to use the functions detrend() and chron() from the dplR package on >300 tree-ring width datasets (.rwl files), of differing lengths. Rather than copying and pasting the code for each object, I would like to do this simultaneously. After some google-ing, it looks like I need to develop a for loop, but I have not had much luck after some troubleshooting. Could someone help put me in the right direction? Below is my current code.
    ##read data files in
    or001 <- read.rwl("or001.rwl", format = "tucson")
    or002 <- read.rwl("or002.rwl", format = "tucson")
    or004 <- read.rwl("or004.rwl", format = "tucson")
    #detrend - negex method
    or001.negex <- detrend(or001, nyrs = NULL, method = "ModNegExp", f = 0.5,
                   pos.slope = FALSE)
    or002.negex <- detrend(or002, nyrs = NULL, method = "ModNegExp", f = 0.5,
                   pos.slope = FALSE)
    or004.negex <- detrend(or004, nyrs = NULL, method = "ModNegExp", f = 0.5,
                   pos.slope = FALSE)
    #build final chronology 
    or001.negex.crn <- chron(or001.negex, prefix = 'OR')
    or002.negex.crn <- chron(or002.negex, prefix = 'OR')
    or004.negex.crn <- chron(or004.negex, prefix = 'OR')
    #export final chronologies
    write_excel_csv(or001.negex.crn, path = "or001.negex.crn.csv")
    write_excel_csv(or002.negex.crn, path = "or002.negex.crn.csv")
    write_excel_csv(or004.negex.crn, path = "or004.negex.crn.csv")
    
 
     
    