Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

Inner join between single csv (in a list of files) and progressive columns of a dataframe in R

I have such a messy issue to solve. I have a list of 318 .csv (DF) and a dataset (raw_data) that has per each column a value "var" with increase index (var_1,var_2,var_3 etc.).

What I wanna do is to inner_join the column var_1 at the first .csv, the column var_2 at the second .csv and so on. Important the inner_join has to be done by="species" inside the single csv.

Following my tries:

 DF_1 = lapply(DF, function(x){
 DF_2 <-  inner_join(x,(3,ncol(raw_data),2),by="species")})

OR 

 DF_2 <- NULL
 i <- 1
 for (j in seq(3,ncol(raw_data),2)) { 
 DF_2[[i]] <-  inner_join(DF,by="species")
 i <- i + 1 }

Hope you can help, I am getting crazy with it. Thanks a million

question from:https://stackoverflow.com/questions/65617474/inner-join-between-single-csv-in-a-list-of-files-and-progressive-columns-of-a

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Can you add an example of the structure of the a few of the csv files? It's difficult to replicate your problem exactly otherwise. For example, can you give the first 5 rows of the first 5 csv files with fake data or similar data?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...