I have 10 csv files that have the same data.frame structure [75 x 1259]. They were imported in R using a list. I want to take the same columns in each csv file and create a new data.frame [75 X 11], so at the end I have 1259 data frames of 75 X 11 (11 columns, because the first column is the same in every data.frame so it can be used for the “by=” argument).
I used to have a code that can do this for 3 data.frame, which wasn’t very sophisticated.
Tab<-function(k){
left_join(select(Ini1, c("value",k)), select(Aug2, c("value",k)), by="value") %>%
left_join(., select(Dim2, c("value",k)), by="value") }
for (k in 2:1258) {
write.csv(data.frame(Tab(k)), paste0('/Users/Tableau des features/',k,'.csv'), row.names = T)
I would love if I wasn’t obliged to do 7 more pipes. I read this Simultaneously merge multiple data.frames in a list to help me understand merging multiple data.frame. The code below sound good.
csv.list %>% reduce(left_join, by="value")
The only problem is how I select the columns I want to merge.