I have 7 .csv files (each representing a location - Site1, Site2, Site3... Site7) in one folder and every .csv file contains 5 columns: ID, month, year, Species (with around 30 levels; different species), values(1, 2, 3, 4 - each of the number represents the intensity of flowering). I do not want to combine all the files together, as they contain different species and IDs, but instead I want to apply the same code that does a lot of cuts, interpolation and creates a named list of time series to all of them. At the end, the code gives a list of time series for each Species. At the moment I created a code that can be applied to only one site.
data_list <- list() #create a list to fill in later
for(sp in levels(Site1$Species)){
dat.sp <- Site1[Site1$Species == sp,] # Distinguish between all Species
tree_list <- list()
for (i in unique(dat.sp$ID)){
other bit of code that cuts the data,
interpolates it and makes it as time
series.
data_list[[sp]]<-tree_list
How should I create the loop to run the same code to every Site ?