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:

> merge_year <- 1986
> 
> for (i in 1:10) { # Number of file pairs
+     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: 


> colnames(arun_1986)
[1] "Latitude"  "Longitude" "Sim_1986" 
> colnames(fekete_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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to