I have a number of equally sized matrices in a list:
I merged them with Reduce and join:
env.all <- Reduce(function(...) left_join(..., by = c('X1', 'X2')), dists.can) 
But since all the joinable columns in the data.frames are equally called "value", the names of the new data.frame are awkward:
names(env.all)
[1] "X1"            "X2"            "value.x"       "value.y"       "value.x.x"     "value.y.y"     "value.x.x.x"   "value.y.y.y"  
 [9] "value.x.x.x.x" "value.y.y.y.y" "value" 
In order to prevent this, i thought of renaming each column $value in dist.can with the name of the parental data.frame, so that eg. dist.can$aridity$value becomes e.g. "dist.can$aridity$aridity".
dists.can <- lapply(dists.can, function(x) {names(x$value) <- names(x);x})
But this failed. It does nothing. How can i achieve this?
toy data:
dist.can <- list(Name1=data.frame(X1=LETTERS[1:10], X2=letters[1:10], value=runif(10)),
     Name2=data.frame(X1=LETTERS[1:10], X2=letters[1:10], value=runif(10)),
     Name3=data.frame(X1=LETTERS[1:10], X2=letters[1:10], value=runif(10)))

 
    