You desperately need to read the Posting Guide (mentioned in the footer of this email) which warns you not to post in HTML format, and learn how to make a reproducible example (e.g. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example).
The problem lies in some interaction between your data and code, and without both we cannot help you. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On April 2, 2014 12:15:51 PM PDT, Abugri James <jabu...@uds.edu.gh> wrote: >I ran the following loop on my SNP data and got an error message as >indicated >for (i in genenames){ >+ current <- fst1[which(fst1$Gene == i),] >+ num <- nrow(current) >+ fst <- max(current$fst) >+ position <- mean(current$pos) >+ nposition <- mean(current$newpos) >+ numhigh <- nrow(current[which(current$fst > threshold),]) >+ colors <- mean(current$colors) >+ output <- matrix(NA,nrow=1,ncol=8) >+ numthresh <- paste("# SNPs > Fst = ", threshold, sep="") >+ colnames(output) <- c("gene", "gene_old", "pos", "newpos", "# >Snps", >numthresh, "Max.Fst", "colors") >+ output[1,1] <- i >+ output[1,2] <- as.character(current[1, "gene_old"]) >+ output[1,3] <- position >+ output[1,4] <- nposition >+ output[1,5] <- num >+ output[1,6] <- numhigh >+ output[1,7] <- fst >+ output[1,8] <- colors >+ maxfstgene <- rbind(maxfstgene, output) >+ } >Error in output[1, 2] <- as.character(current[1, "gene_old"]) : > replacement has length zero >In addition: Warning message: >In mean.default(current$pos) : > argument is not numeric or logical: returning NA >-- ______________________________________________ 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.