0

I am student in highschool with assignment in EXCEL. I did it now want to see if this is how to make it explicable in R statistical software. This is just simply example but say there is up to File25

File1 is

City    Population  GDP             
A       100         700
B       150         800 
C       80          740

File2 is

City    Import      Export              
A       520         420
B       425         420 
C       200         340

File3 is

City    Average Income  Average Saving              
A       10              70
B       15              80  
C       8               74

Output is

City    Population  GDP   Import    Average Saving      
A       100         700    520      70
B       150         800    425      80
C       80          740    200      74

enter code here

File1[,c("City","Population","GDP")]
File2[,c("City","Import")]
File3[,c("City","Average Saving")]

This says to take the VARS necessary and to MATCH the city and then to combine them all do like this

multmerge = function(D:/FILES){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.txt(file=x,header=T)})
Reduce(function(x,y) {merge(x, y, by = intersect(City, City),}, datalist)
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
tieo3
  • 9
  • 1

0 Answers0