There is a list l1
of data.frames:
head(lapply(l1,head,n=3),3)
[[1]]
nu_pregao pcVar
1 2371 7.224848
45 2372 2.797704
89 2373 3.947368
[[2]]
nu_pregao pcVar
2 2371 4.055709
46 2372 2.944882
90 2373 3.507937
[[3]]
nu_pregao pcVar
3 2371 4.011461
47 2372 3.679907
91 2373 4.693034
If one uses Reduce
to merge them
l2=Reduce(function(x,y) merge(x,y, by='nu_pregao'),l1)
There were 41 warnings (use warnings() to see them)
gets a sequence of warnings like this:
1: In merge.data.frame(x, y, by = "nu_pregao") :
column names ‘pcVar.x’, ‘pcVar.y’ are duplicated in the result
The result is ok, the only problem are the duplicated names.
Is there a way to avoid this?
I´ve seen question How to merge multiple data.frames and sum and average columns at the same time in R but it seems it does rbind
instead of merge
.