Ettinger, Nicholas
2005-Nov-03 21:53 UTC
[R] Error message: " The following object(s) are masked"
Hello! First time posting here: Here is my code: x <- c(1:22) finaloutput=cidrm=NULL finaldiversityoutput=diversitym=NULL diversityinfo=read.table("Diversity_info.txt", header=T, sep="\t", row.names=NULL) attach(diversityinfo) diversitynr=nrow(diversityinfo) diversitytemp <- matrix(0,nrow=diversitynr,ncol=1) for(j in 1:length(x)) { diversitym=read.table(paste(paste("Div-Chr",x[j], sep=""),"_corr.txt",sep=""), header=T, sep="\t", row.names=NULL) attach(diversitym) diversitytemp <- cbind(diversitytemp,diversitym) print(paste(paste("Diversity-Chrom",x[j], sep=""),".txt",sep="")) print(dim(diversitytemp)) } I am essentially trying to combine several tab-delimited text data files together into one big file. I recently upgraded to R 2.2.0. I now get multiple error messages of the form: The following object(s) are masked from diversitym ( position 4 ) : X X.1 X.2 I searched on "masked" and read the manual about "conflicts" but I don't really understand what the issue is. I didn't get this error message, using the same code with R 2.1.0. Can somebody help (I'm not a programmer). [[alternative HTML version deleted]]
Ettinger, Nicholas wrote:> Hello! > > First time posting here: > > Here is my code: > > x <- c(1:22) > finaloutput=cidrm=NULL > finaldiversityoutput=diversitym=NULL > > diversityinfo=read.table("Diversity_info.txt", header=T, sep="\t", > row.names=NULL) > attach(diversityinfo) > diversitynr=nrow(diversityinfo) > diversitytemp <- matrix(0,nrow=diversitynr,ncol=1) > > for(j in 1:length(x)) > { > diversitym=read.table(paste(paste("Div-Chr",x[j], > sep=""),"_corr.txt",sep=""), header=T, sep="\t", row.names=NULL) > attach(diversitym) > diversitytemp <- cbind(diversitytemp,diversitym) > print(paste(paste("Diversity-Chrom",x[j], sep=""),".txt",sep="")) > print(dim(diversitytemp)) > } > > I am essentially trying to combine several tab-delimited text data files > together into one big file. > > I recently upgraded to R 2.2.0. I now get multiple error messages of > the form: > The following object(s) are masked from diversitym ( position 4 ) : > > X X.1 X.2These are *Warning* messges, not errors. You are using attach but never detach in your loop. Each attach masks the objects you have attached formerly, because there are the same names in it, obviously. Your code works as before, but you should not use attach without detaching. I'd suggest not to use attach() at all unless you know what you are doing and it really improved convenience in interactive analyses. Uwe Ligges> I searched on "masked" and read the manual about "conflicts" but I don't > really understand what the issue is. I didn't get this error message, > using the same code with R 2.1.0. Can somebody help (I'm not a > programmer). > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html