I have 360 dataframes (each containing 1 column with species names) named "sp_i_j", where i goes from 1 to 30 (corresponding to 30 samples) and j from 1 to 12 (corresponding to 12 replicates per sample) -> sp_1_1, sp_1_2,..., sp_30_11, sp_30_12.
For example, sp_1_1 is like that:
>sp_1_1
                       species
1       Cynoglossus bilineatus
2         Denticeps clupeoides
3         Gnathopogon imberbis
4     Grasseichthys gabonensis
5              Howella brodiei
sp_2_1 looks like that:
> sp_2_1
                         species
1           Acipenser fulvescens
2  Acrossocheilus stenotaeniatus
3               Allocyttus niger
4          Anguilla celebesensis
5              Aulopyge huegelii
And I have 30 other dataframes named "species_s1" to "species_s30" also containing only 1 column with species names.
species_s1 is like that:
> species_s1
                       species
1    Pseudaspius leptocephalus
2         Denticeps clupeoides
3              Howella brodiei
4  Microphysogobio tafangensis
5      Semotilus atromaculatus
6     Grasseichthys gabonensis
and species_s2 is like that:
> species_s2
                           species
1                Geotria australis
2           Odontamblyopus rebecca
3           Neocyttus rhomboidalis
4                      Tinca tinca
5                Aulopyge huegelii
6           Rastrelliger kanagurta
I want to apply the following function to all of the 360 dataframes:
TP <- nrow(inner_join(sp_1_1, species_s1))
So that all the dataframes starting with "sp_1_" are compared to "species_s1", dataframes starting with "sp_2_" are compared to "species_s2", and so on.
And I would like to store the results in a unique dataframe of 30 columns (corresponding to the samples) and 12 lines (corresponding to the replicates). So that the results of the comparisons of df "sp_1_1" to "sp_1_12" with "species_s1" will be stored in the 12 lines of the first column; results of the comparisons of df "sp_2_1" to "sp_2_12" with "species_s2" will be stored in the 12 lines of the second column; and so on.
I tried something like that:
for (i in 1:30) {
  for (j in 1:12) {
    TP[i,j] <- nrow(inner_join(sp_[i]_[j], species_s[i]))
  }
}
But obviously that doesn't work.
Any suggestions?
 
    