[Rcolony-commits] r80 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 10 15:16:15 CET 2012


Author: jonesor
Date: 2012-12-10 15:16:15 +0100 (Mon, 10 Dec 2012)
New Revision: 80

Modified:
   pkg/R/get.colony.data.R
Log:
Simplified how number of offspring were found. Added  code to strip out empty lines

Modified: pkg/R/get.colony.data.R
===================================================================
--- pkg/R/get.colony.data.R	2012-12-10 10:10:57 UTC (rev 79)
+++ pkg/R/get.colony.data.R	2012-12-10 14:16:15 UTC (rev 80)
@@ -1,4 +1,4 @@
-get.colony.data<-function(datadir, filename = list.files(datadir, pattern = ".DAT")){
+get.colony.data<-function(datadir, filename = list.files(datadir, pattern = ".DAT", ignore.case=TRUE)){
     
     #Test to see if colony has finished running.
     t1 <- list.files(path = datadir, pattern = "Maternity")[1]
@@ -9,11 +9,13 @@
 
     #Test consistency of the database file. Throw warnings/errors as necessary
     colony.object <- NULL
-    x <- readLines(paste(datadir, filename, sep = ""))
+    x <- readLines(paste(datadir, filename, sep = "/"))
     
+    #Strip out empty rows, if there are any.
+    if(length(which(x == "")) > 0){x = x[-which(x == "")]}
+
     #Extract the number of offspring from the dat file. This information is used for error checking later on.
     n <- x[3]
-    n <- sub("! I, Number of offspring in the sample", "", n)
     n <- sub("^[\t\n\f\r ]*", "", n) #remove leading whitespace
     n <- as.numeric(gsub("([A-Za-z0-9]*)([!0-9A-Za-z ]*)", "\\1", n, perl = TRUE))
     



More information about the Rcolony-commits mailing list