On 02/04/2014, 3:15 PM, Abugri James wrote:
I ran the following loop on my SNP data and got an error message as indicated
I would assume that the error message is accurate: as.character(current[1, "gene_old"]) has length zero. You'll need to debug why that happened.
Duncan Murdoch
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.