[Genabel-commits] r800 - pkg/DatABEL/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Oct 20 18:26:09 CEST 2011
Author: lckarssen
Date: 2011-10-20 18:26:09 +0200 (Thu, 20 Oct 2011)
New Revision: 800
Modified:
pkg/DatABEL/R/databel2matrix.R
Log:
In databel2matrix():
- fixed mistake in documentation
- Added check for total number of elements in the matrix. This should not be larger than what R can handle.
Modified: pkg/DatABEL/R/databel2matrix.R
===================================================================
--- pkg/DatABEL/R/databel2matrix.R 2011-10-20 11:48:29 UTC (rev 799)
+++ pkg/DatABEL/R/databel2matrix.R 2011-10-20 16:26:09 UTC (rev 800)
@@ -1,27 +1,30 @@
#' converts 'databel' to matrix
-#'
-#' Converts regular R matrix to \code{\linkS4class{databel}} object.
-#' This is the procedure used by "as" converting to DatABEL objects,
-#' in which case a temporary file name is created
-#'
+#'
+#' Converts a \code{\linkS4class{databel}} object to a regular R matrix.
+#' This is the procedure used by the "as" converting to DatABEL objects,
+#' in which case a temporary file name is created.
+#'
#' @param from 'databel' matrix
#' @param rows which rows to include
#' @param cols which columns to include
-#'
+#'
#' @return object of \code{\linkS4class{matrix}} class
-#'
+#'
#' @author Stepan Yakovenko
-#'
+#'
databel2matrix <- function(from, rows, cols) {
newi <- convert_intlogcha_index_to_int(rows,from,1)
- newj <- convert_intlogcha_index_to_int(cols,from,2)
+ newj <- convert_intlogcha_index_to_int(cols,from,2)
+
+ if (newi * newj > (2^31 -1))
+ stop("The matrix has too many elements for R, see ?'Memory-limits'.")
+
ret <- matrix(1.2345678912345, length(newi),length(newj));
if(!.Call("assignDoubleMatrix", from at data, newi, newj, ret, as.integer(1)))
- stop("databel [<-: can't write variable.");
+ stop("databel [<-: can't write variable.");
dimnames(ret) <- dimnames(from)
- return(ret)
+ return(ret)
}
-
More information about the Genabel-commits
mailing list