[R] Problems with 'valid columns' when using merge
Steve Murray
smurray444 at hotmail.com
Fri May 1 14:51:53 CEST 2009
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
More information about the R-help
mailing list