Your parameters to merge do not appear to be objects; they are strings, You might want to try:
merge(x=get(paste("arunoff_",start_arunoff, sep="")), y........ You might want to consider a 'list' for storing your data. Also are you ever 'detach'ing? It is useful to find ways to avoid 'attach' (IMHO). On Fri, May 1, 2009 at 8:51 AM, Steve Murray <smurray...@hotmail.com> wrote: > > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] ______________________________________________ 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.