I have a list of 33 dataframes (each dataframe has a different number of rows). I am trying to write a nested for loop that will go through each dataframe in the list, and then go through each row within that dataframe and apply a function, before coming out again and moving onto the next dataframe in the list. However, Im not sure how to index a specific row within a dataframe within a list. If anyone knows how to do this or a more efficient way of doing this it would be much appreciated. Thanks.
for (i in 1:length(data.list)) {
#Creating a matrix of all possible combinations of pairs in order to do pairwise comparisons on all of the sites
pairs = t(combn(nrow(data.list[[i]]), m = 2))
#Some more data wrangling
pairs <- as.data.frame(pairs)
colnames(pairs) <- c("PaperOneRowNumber", "PaperTwoRowNumber")
pairs$LRR <- 0
pairs$LRR_var <- 0
for (j in 1:nrow(pairs)) {
#print(i)
#Assigning Paper IDs to variables
a <- pairs[j,1]
b <- pairs[j,2]
#print(a)
#print(b)
paperone <- data.list[[i[a,]]]
papertwo <- data.list[[i[b,]]]
#print(paperone)
#print(papertwo)
#Inputting variables into calc.effect function and saving the output
effect.size <- calc.effect(paperone, papertwo)
#print(effect.size)
pairs$LRR[j] <- effect.size$LRR
pairs$LRR_var[j] <- effect.size$LRR_var
}
}