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 --
-- * "The information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person."* [[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.