I have four different data frames. They are named "data_QB", "data_WR", "data_RB", and "data_TE". I want to get the interquartile range of a common variable in each of them ("ppr") and assign these values to "iqr_QB", "iqr_WR", "iqr_RB", and "iqr_TE", respectively. I'd like to do this without having to repeat the code four times.
I tried
clist = c("QB", "WR", "RB", "TE")
for (i in clist) {
assign(paste0("iqr_", i)), IQR(assign(paste0("data_", i)$ppr)))
}
but I got the error message:
Error: $ operator is invalid for atomic vectors
Does anyone know how I could do this? Any help would be greatly appreciated!
lapply(list(your_dataframes), function(i)IQR(i$your_var))- Sotos