[Rcolony-commits] r82 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 10 16:37:17 CET 2012
Author: jonesor
Date: 2012-12-10 16:37:17 +0100 (Mon, 10 Dec 2012)
New Revision: 82
Modified:
pkg/R/get.colony.data.R
Log:
Fixed code to obtain mothers and fathers rows from row number rather than GREP
Modified: pkg/R/get.colony.data.R
===================================================================
--- pkg/R/get.colony.data.R 2012-12-10 15:10:15 UTC (rev 81)
+++ pkg/R/get.colony.data.R 2012-12-10 15:37:17 UTC (rev 82)
@@ -23,15 +23,15 @@
#Lists of offspring, fathers and mothers
###################################################
# Starts at line 24 - 24+(n-1)
- offspring <-x[24:(24+(n-1))]
+ offspring <- x[24:(24 + (n - 1))]
+
+ nFathers <- as.numeric(strsplit(x[25 + n], split = " +")[[1]][1])
+ nMothers <- as.numeric(strsplit(x[25 + n], split = " +")[[1]][2])
- fathers <- x[grep("!Candidate M ID and genotypes",x):(grep("!Candidate F ID and genotypes",x) - 2)] #M for male, F for female
- fathers <- fathers[fathers != ""]
-
- mothers <- x[grep("!Candidate F ID and genotypes",x):(grep("!Number of offspring with known father",x) - 3)] #M for male, F for female
- mothers <- mothers[mothers != ""]
-
- #remove leading whitespace
+ fathers <- x[(24 + (n + 2)):(24 + (n + 1) + nFathers)]
+ mothers <- x[(24 + (n + 2) + nFathers):(24 + (n + 1) + nFathers + nMothers)]
+
+ #Remove leading whitespace
offspring <- sub("^[\t\n\f\r ]*", "", offspring) #remove leading whitespace
fathers <- sub("^[\t\n\f\r ]*", "", fathers) #remove leading whitespace
mothers <- sub("^[\t\n\f\r ]*", "", mothers) #remove leading whitespace
More information about the Rcolony-commits
mailing list