[Rcpp-commits] r3289 - in pkg/int64: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 6 17:00:16 CET 2011
Author: romain
Date: 2011-11-06 17:00:16 +0100 (Sun, 06 Nov 2011)
New Revision: 3289
Modified:
pkg/int64/ChangeLog
pkg/int64/R/int64.R
pkg/int64/man/int64-class.Rd
pkg/int64/man/uint64-class.Rd
Log:
adding names and names<-
Modified: pkg/int64/ChangeLog
===================================================================
--- pkg/int64/ChangeLog 2011-11-06 03:59:52 UTC (rev 3288)
+++ pkg/int64/ChangeLog 2011-11-06 16:00:16 UTC (rev 3289)
@@ -1,5 +1,10 @@
-2011-11-012 Romain Francois <romain at r-enthusiasts.com>
+2011-11-06 Romain Francois <romain at r-enthusiasts.com>
+ * R/int64.R: adding names and names<- to show 64 big integer vectors with
+ names
+
+2011-11-01 Romain Francois <romain at r-enthusiasts.com>
+
* R/int64.R: implementation of sort for int64 and uint64
* inst/include/int64/LongVector.h: LongVector<>::sort
Modified: pkg/int64/R/int64.R
===================================================================
--- pkg/int64/R/int64.R 2011-11-06 03:59:52 UTC (rev 3288)
+++ pkg/int64/R/int64.R 2011-11-06 16:00:16 UTC (rev 3289)
@@ -16,9 +16,40 @@
# You should have received a copy of the GNU General Public License
# along with int64. If not, see <http://www.gnu.org/licenses/>.
-setClass( "int64", contains = "list" )
-setClass( "uint64", contains = "list" )
+setClassUnion( "maybeNames", c("character", "NULL" ) )
+names_int64 <- function(x){
+ x at NAMES
+}
+namesgets_int64 <- function( x, value){
+ if( missing(value) || is.null(value) ){
+ x at NAMES <- NULL
+ } else if( is.character( value )){
+ if( length( value ) == length( x at .Data ) ){
+ x at NAMES <- value
+ } else if(length(value) < length(x at .Data) ) {
+ x at NAMES <- c( value, rep( NA, length(x at .Data) - length(value) ) )
+ } else {
+ stop( "error assigning names" )
+ }
+ } else {
+ stop( "must be character vector or NULL" )
+ }
+ x
+}
+setClass( "int64", contains = "list",
+ representation( NAMES = "maybeNames")
+)
+setClass( "uint64", contains = "list" ,
+ representation( NAMES = "maybeNames")
+)
+
+setMethod( "names", "int64", names_int64 )
+setMethod( "names<-", "int64", namesgets_int64 )
+setMethod( "names", "uint64", names_int64 )
+setMethod( "names<-", "uint64", namesgets_int64 )
+
+
setClass( "binary",
representation( data = "character", bits = "integer" )
)
@@ -56,14 +87,18 @@
setMethod( "length", "uint64", function(x){
length(x at .Data)
} )
-setMethod( "show", "int64", function(object){
- print( noquote( as.character( object ) ) )
+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))
+ }
invisible(object)
-} )
-setMethod( "show", "uint64", function(object){
- print( noquote( as.character( object ) ) )
- invisible(object)
-} )
+}
+setMethod( "show", "int64", show_int64)
+setMethod( "show", "uint64", show_int64)
as.int64 <- function(x){
new( "int64", .Call(int64_as_int64, x) )
Modified: pkg/int64/man/int64-class.Rd
===================================================================
--- pkg/int64/man/int64-class.Rd 2011-11-06 03:59:52 UTC (rev 3288)
+++ pkg/int64/man/int64-class.Rd 2011-11-06 16:00:16 UTC (rev 3289)
@@ -10,6 +10,8 @@
\alias{Arith,int64,ANY-method}
\alias{Arith,int64,int64-method}
\alias{as.character,int64-method}
+\alias{names,int64-method}
+\alias{names<-,int64-method}
\alias{as.data.frame,int64-method}
\alias{Compare,ANY,int64-method}
\alias{Compare,int64,ANY-method}
@@ -32,6 +34,8 @@
\describe{
\item{\code{.Data}:}{list of integer vectors of length 2. Each
int64 number is coded as two integers. }
+ \item{\code{NAMES}:}{Used for names of vectors. This is only being
+ used through the \code{names} and \code{names<-} functions. }
}
}
\section{Extends}{
Modified: pkg/int64/man/uint64-class.Rd
===================================================================
--- pkg/int64/man/uint64-class.Rd 2011-11-06 03:59:52 UTC (rev 3288)
+++ pkg/int64/man/uint64-class.Rd 2011-11-06 16:00:16 UTC (rev 3289)
@@ -10,6 +10,8 @@
\alias{Arith,uint64,ANY-method}
\alias{Arith,uint64,uint64-method}
\alias{as.character,uint64-method}
+\alias{names,uint64-method}
+\alias{names<-,uint64-method}
\alias{as.data.frame,uint64-method}
\alias{Compare,ANY,uint64-method}
\alias{Compare,uint64,ANY-method}
@@ -32,6 +34,8 @@
\describe{
\item{\code{.Data}:}{list of integer vectors of length 2. Each
uint64 number is coded as two integers. }
+ \item{\code{NAMES}:}{Used for names of vectors. This is only being
+ used through the \code{names} and \code{names<-} functions. }
}
}
\section{Extends}{
More information about the Rcpp-commits
mailing list