[Rcpp-commits] r3395 - in pkg/int64: . R inst inst/doc man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 23 15:15:02 CET 2011


Author: romain
Date: 2011-11-23 15:15:01 +0100 (Wed, 23 Nov 2011)
New Revision: 3395

Added:
   pkg/int64/inst/NEWS
Modified:
   pkg/int64/ChangeLog
   pkg/int64/R/int64.R
   pkg/int64/inst/doc/int64.Rnw
   pkg/int64/man/int64-package.Rd
   pkg/int64/man/uint64.Rd
Log:
implementing setAs

Modified: pkg/int64/ChangeLog
===================================================================
--- pkg/int64/ChangeLog	2011-11-22 09:46:03 UTC (rev 3394)
+++ pkg/int64/ChangeLog	2011-11-23 14:15:01 UTC (rev 3395)
@@ -1,3 +1,14 @@
+2011-11-23  Romain Francois  <romain at r-enthusiasts.com>
+
+    * R/int64.R: implementing setAs so that read.csv can handle colClasses = "int64"
+    and "uint64". Suggestion from Gabor Grothendieck on R-devel
+    
+    * R/int64.R: show.[u]int64 did not handle zero length vectors correctly
+    
+    * man/int64.Rd: cross links with uint64.Rd
+    
+    * man/uint64.Rd: cross links with int64.Rd
+
 2011-11-06  Romain Francois  <romain at r-enthusiasts.com>
 
     * R/int64.R: adding names and names<- to show 64 big integer vectors with

Modified: pkg/int64/R/int64.R
===================================================================
--- pkg/int64/R/int64.R	2011-11-22 09:46:03 UTC (rev 3394)
+++ pkg/int64/R/int64.R	2011-11-23 14:15:01 UTC (rev 3395)
@@ -88,12 +88,16 @@
     length(x at .Data)
 } )
 show_int64 <- function(object){
-    if( is.null( object at NAMES ) ){
-        print( noquote( as.character( object ) ) )
-    } else {
-        x <- as.character( object )
-        names(x) <- object at NAMES
-        print(noquote(x))
+    if( !length(object)) {
+        writeLines( sprintf( "%s(0)", class(object) ) )
+    } else { 
+        if( is.null( object at NAMES ) ){
+            print( noquote( as.character( object ) ) )
+        } else {
+            x <- as.character( object )
+            names(x) <- object at NAMES
+            print(noquote(x))
+        }
     }
     invisible(object)
 } 
@@ -310,3 +314,12 @@
 setAs("character", "int64", function(from) as.int64(from))
 setAs("character", "uint64", function(from) as.uint64(from))
 
+setAs("integer", "int64", function(from) as.int64(from))
+setAs("integer", "uint64", function(from) as.uint64(from))
+
+setAs("logical", "int64", function(from) as.int64(from))
+setAs("logical", "uint64", function(from) as.uint64(from))
+
+setAs("numeric", "int64", function(from) as.int64(from))
+setAs("numeric", "uint64", function(from) as.uint64(from))
+

Added: pkg/int64/inst/NEWS
===================================================================
--- pkg/int64/inst/NEWS	                        (rev 0)
+++ pkg/int64/inst/NEWS	2011-11-23 14:15:01 UTC (rev 3395)
@@ -0,0 +1,5 @@
+1.1.0   2011-yy-zz
+
+    o   Implemented setAs so that read.csv can handle colClasses = "int64"
+    and "uint64" using Gabor Grothendieck suggestion on R-devel
+

Modified: pkg/int64/inst/doc/int64.Rnw
===================================================================
--- pkg/int64/inst/doc/int64.Rnw	2011-11-22 09:46:03 UTC (rev 3394)
+++ pkg/int64/inst/doc/int64.Rnw	2011-11-23 14:15:01 UTC (rev 3395)
@@ -285,6 +285,20 @@
 
 $$[0,2^{64}-2]$$
 
+\section{Reading 64 bit integers from files}
 
+The \texttt{int64} implements the necessary methods so that \texttt{read.csv}
+can read signed and unsigned 64 bit integers from files. 
+
+<<>>=
+tf <- tempfile()
+df <- data.frame( x = 1:10, y = 1:10, z = 1:10 )
+write.table( df, tf, sep = ",", row.names = FALSE )
+df <- read.csv( tf, colClasses = c("integer", "int64", "uint64" ) )
+df
+sapply( df, class )
+@
+
+
 \end{document}
 

Modified: pkg/int64/man/int64-package.Rd
===================================================================
--- pkg/int64/man/int64-package.Rd	2011-11-22 09:46:03 UTC (rev 3394)
+++ pkg/int64/man/int64-package.Rd	2011-11-23 14:15:01 UTC (rev 3395)
@@ -11,8 +11,8 @@
 \tabular{ll}{
 Package: \tab int64\cr
 Type: \tab Package\cr
-Version: \tab 1.0\cr
-Date: \tab 2011-10-21\cr
+Version: \tab 1.1.0\cr
+Date: \tab 2011-10-23\cr
 License: \tab GPL (>= 2)\cr
 LazyLoad: \tab yes\cr
 }

Modified: pkg/int64/man/uint64.Rd
===================================================================
--- pkg/int64/man/uint64.Rd	2011-11-22 09:46:03 UTC (rev 3394)
+++ pkg/int64/man/uint64.Rd	2011-11-23 14:15:01 UTC (rev 3395)
@@ -25,7 +25,7 @@
     into \code{\linkS4class{uint64}} vectors. 
     
     \code{\link{int64}} for signed 64 bit integer vectors, i.e. of class
-    \code{\linkS4class{int64}. 
+    \code{\linkS4class{int64}}. 
 }
 \examples{
 x <- uint64(10L)



More information about the Rcpp-commits mailing list