[Raster-commits] r130 - pkg/raster/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 13 09:16:43 CET 2009


Author: rhijmans
Date: 2009-01-13 09:16:43 +0100 (Tue, 13 Jan 2009)
New Revision: 130

Modified:
   pkg/raster/R/read.inifile.R
Log:


Modified: pkg/raster/R/read.inifile.R
===================================================================
--- pkg/raster/R/read.inifile.R	2009-01-13 07:53:54 UTC (rev 129)
+++ pkg/raster/R/read.inifile.R	2009-01-13 08:16:43 UTC (rev 130)
@@ -10,26 +10,27 @@
 # e.g. "projection = +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"
 
 
+.strSplitOnFirstToken <- function(s, token="=") {
+	pos <- which(strsplit(s, '')[[1]]==token)[1]
+	if (is.na(pos)) {
+		return(c(trim(s), NA)) 
+	} else {
+		first <- substr(s, 1, (pos-1))
+		second <- substr(s, (pos+1), nchar(s))
+		return(trim(c(first, second)))
+	}
+}
+
+
 readIniFile <- function(filename) {
     if (!file.exists(filename)) { stop(paste(filename, " does not exist")) }
 	
-	strSplitOnFirstToken <- function(s, token="=") {
-		pos <- which(strsplit(s, '')[[1]]==token)[1]
-		if (is.na(pos)) {
-			return(c(trim(s), NA)) 
-		} else {
-			first <- substr(s, 1, (pos-1))
-			second <- substr(s, (pos+1), nchar(s))
-			return(trim(c(first, second)))
-		}
-	}
-	
 	Lines <- readLines(filename)
 # ";" is the start of a comment .
-	strsplitcomment <- function(s) {strSplitOnFirstToken(s, token=";")}
+	strsplitcomment <- function(s) {.strSplitOnFirstToken(s, token=";")}
 	ini <- lapply(Lines, strsplitcomment) 
 	Lines <- matrix(unlist(ini), ncol=2, byrow=T)[,1]
-	ini <- lapply(Lines, strSplitOnFirstToken) 
+	ini <- lapply(Lines, .strSplitOnFirstToken) 
  	ini <- matrix(unlist(ini), ncol=2, byrow=T)
 	ini <- subset(ini, ini[,1] != "")
 



More information about the Raster-commits mailing list