Skip to content

Problems with 'valid columns' when using merge

2 messages · Steve Murray, jim holtman

#
Dear all,

I am trying to use 'merge' within a loop, however, I receive an error relating to the 'by' argument of the command, as follows:
+     assign(paste("merged_arunfek_", merge_year, sep=""), merge(x=paste("arunoff_",start_arunoff, sep=""), y=paste("fekete_", start_fekete, sep=""), by=c("Latitude", "Longitude"), sort=FALSE))
+     attach(paste("merged_arunfek_", merge_year))
+     merge_year = merge_year+1
+     }
Error in fix.by(by.x, x) : 'by' must specify valid column(s)


However, as far as I can tell, the column names (as stated in the above code) appear to be valid:
[1] "Latitude"  "Longitude" "Sim_1986"
[1] "Latitude"  "Longitude" "X1986"


I'm trying to merge based on both the Latitude and Longitude column and have used by=c("name_x", "name_y") before without too many problems. Any suggestions would be gratefully received.

Many thanks,

Steve