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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 12 02:10:14 CET 2009


Author: rhijmans
Date: 2009-01-12 02:10:14 +0100 (Mon, 12 Jan 2009)
New Revision: 118

Modified:
   pkg/raster/R/values.R
Log:


Modified: pkg/raster/R/values.R
===================================================================
--- pkg/raster/R/values.R	2009-01-12 00:45:05 UTC (rev 117)
+++ pkg/raster/R/values.R	2009-01-12 01:10:14 UTC (rev 118)
@@ -1,9 +1,9 @@
 
 values <- function(object, format='vector', names=FALSE) {
-	if (object at data@content=="nodata") {stop("first read some data (e.g., readAll()") }
+	if (dataContent(object)=="nodata") {stop("first read some data (e.g., readAll()") }
 	if (format=='matrix') { 
 		return(.values.as.matrix(object, names)) 
-	if (format=='dataframe') { 
+	} else if (format=='dataframe') { 
 		return(.values.as.dataframe(object)) 
 	} else {
 		return(object at data@values) 
@@ -42,8 +42,8 @@
 
 
 .values.as.dataframe <- function(raster) {
-	m <- as.data.frame(values.as.matrix(raster, FALSE))
-	if raster at data@colnames != '' { 
+	m <- as.data.frame(.values.as.matrix(raster, FALSE))
+	if (isTRUE(length(raster at data@colnames) == dim(m)[2])) { 
 		colnames(m) <- raster at data@colnames 
 	} else {
 		colnames(m) <- seq(1:ncol(m))



More information about the Raster-commits mailing list