[Distr-commits] r168 - in branches/distr-2.0/pkg/distrSim: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 3 12:42:55 CEST 2008


Author: stamats
Date: 2008-06-03 12:42:54 +0200 (Tue, 03 Jun 2008)
New Revision: 168

Modified:
   branches/distr-2.0/pkg/distrSim/DESCRIPTION
   branches/distr-2.0/pkg/distrSim/NAMESPACE
   branches/distr-2.0/pkg/distrSim/R/AllClasses.R
   branches/distr-2.0/pkg/distrSim/R/SeqDataFrames-Class.R
   branches/distr-2.0/pkg/distrSim/R/subsetting-methods.R
   branches/distr-2.0/pkg/distrSim/man/subsetting-methods.Rd
Log:
distrSim checks and installs without any warning or error under R version 2.8.0 Under development (unstable) (2008-06-02 r45826) but not yet under 2.7.0 patched - "\S4method bug".
There might be a bug in the "[<-"-method for SeqDataFrames - could you check this please, Peter.

Modified: branches/distr-2.0/pkg/distrSim/DESCRIPTION
===================================================================
--- branches/distr-2.0/pkg/distrSim/DESCRIPTION	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/DESCRIPTION	2008-06-03 10:42:54 UTC (rev 168)
@@ -1,6 +1,6 @@
 Package: distrSim
 Version: 2.0
-Date: 2008-05-30
+Date: 2008-06-03
 Title: Simulation classes based on package distr
 Depends: R(>= 2.6.0), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.0), startupmsg
 Suggests: distrEx(>= 2.0)

Modified: branches/distr-2.0/pkg/distrSim/NAMESPACE
===================================================================
--- branches/distr-2.0/pkg/distrSim/NAMESPACE	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/NAMESPACE	2008-06-03 10:42:54 UTC (rev 168)
@@ -5,7 +5,7 @@
 import("startupmsg")
 
 export("cload", "Dataclass", "Simulation", "Contsimulation",
-              "distrSimoptions", "getdistrSimOption", "seqDataFrames", "distrSimMASK")
+              "distrSimoptions", "getdistrSimOption", "SeqDataFrames", "distrSimMASK")
 exportClasses("vectororNULL", "Dataclass", "Simulation", "Contsimulation",
               "SeqDataFrames", "MatrixorNULLorVector","ArrayorNULLorVector",
               "ArrayorNULLorVectororDataframeorSeqDataFrames","DataframeorSeqDataFrames")

Modified: branches/distr-2.0/pkg/distrSim/R/AllClasses.R
===================================================================
--- branches/distr-2.0/pkg/distrSim/R/AllClasses.R	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/R/AllClasses.R	2008-06-03 10:42:54 UTC (rev 168)
@@ -8,11 +8,11 @@
           validity = function(object){
                len <- length(object at data)
                if (len > 1)
-                  { if (!all(lapply(object at data, is.data.frame)))
+                  { if (!all(unlist(lapply(object at data, is.data.frame))))
                         stop("all elements must be data frames")
                     f <- function(y) {list(ncol(y), names(y))}
                     g <- function(y) identical(f(y), f(object at data[[1]]))
-                    if (!all(lapply(object at data, g)))
+                    if (!all(unlist(lapply(object at data, g))))
                         stop("all elements must have the same column structure")     
                   }
               return(TRUE) }

Modified: branches/distr-2.0/pkg/distrSim/R/SeqDataFrames-Class.R
===================================================================
--- branches/distr-2.0/pkg/distrSim/R/SeqDataFrames-Class.R	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/R/SeqDataFrames-Class.R	2008-06-03 10:42:54 UTC (rev 168)
@@ -1,4 +1,4 @@
-seqDataFrames <- function(...) new("SeqDataFrames", data=list(...))
+SeqDataFrames <- function(...) new("SeqDataFrames", data=list(...))
 
 ## Access methods
 

Modified: branches/distr-2.0/pkg/distrSim/R/subsetting-methods.R
===================================================================
--- branches/distr-2.0/pkg/distrSim/R/subsetting-methods.R	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/R/subsetting-methods.R	2008-06-03 10:42:54 UTC (rev 168)
@@ -1,5 +1,5 @@
 setMethod("[", "SeqDataFrames", function(x, i, j, k, drop = FALSE){
-          if(missing(k)) k <- 1:length(x at data)
+          if(missing(k)) k <- seq_len(length(x at data))
           kl <- length(k)
           if (kl == 1){
               daf <- "["(x at data[[k]],i,j, drop = drop)
@@ -7,13 +7,13 @@
                    return(daf)
               else return(new("SeqDataFrames", data = list(daf)))
           }else {
-              kn <- 1: length(x at data)
+              kn <- seq_len(length(x at data))
               if(!is.null(names(x at data)))
                  names(kn) <- names(x at data)
               kl0 <- kn[k]
               kll <- length(kl0)
               lis <- vector("list",kll)
-              for (kk in 1:kll)
+              for (kk in seq_len(kll))
                   {lis[[kk]] <- as.data.frame("["(x at data[[kl0[kk]]], i,j, drop = drop))
                    if(!is.null(names(x at data)))
                       names(lis)[kk] <- names(x at data)[kl0[kk]]}
@@ -21,13 +21,13 @@
           }})
 
 setReplaceMethod("[", "SeqDataFrames", function(x, i, j, k, value){
-          if(missing(k)) k <- 1:length(x at data)
+          if(missing(k)) k <- seq_len(length(x at data))
           if(length(k)==1){
              if((k<=length(x at data))||!is(try(x at data[[k]],silent=TRUE),"try-error"))
                 {zl <- x at data
                  z  <- zl[[k]]
                  if (missing(i))
-                    { i <- 1:nrow(z)
+                    { i <- seq_len(nrow(z))
                      #if(!is.null(dim(value)))
                      #    z <- data.frame(matrix(NA,nrow(value),ncol(x at data[[1]])))
                      #    else z <- data.frame(matrix(NA,length(value),ncol(x at data[[1]])))
@@ -44,21 +44,24 @@
               }
              return(x)}
 
-          if(missing(j)) j <- 1:ncol(x at data[[1]])
-          if(missing(i)) i <- lapply(1:length(x at data),function(y) 1:nrow(x at data[[y]]))
+          if(missing(j)) j <- seq_len(ncol(x at data[[1]]))
+          if(missing(i)) i <- lapply(seq_len(length(x at data)),function(y) seq_len(nrow(x at data[[y]])))
 
           if(is(value, "SeqDataFrames")) value <- value at data
 
-          kn <- 1: length(x at data)
+          kn <- seq_len(length(x at data))
           if(!is.null(names(x at data)))
                  names(kn) <- names(x at data)
           kl0 <- kn[k]
           kll <- length(kl0)
 
-          if(!is.list(i)) i <- lapply(kl0,function(y) i)
+## Is the following line correct?
+## should it be: if(!is.list(i)) i <- lapply(kl0, function(y) y)
+## or: if(!is.list(i)) i <- as.list(kl0)?
+          if(!is.list(i)) i <- lapply(kl0, function(y) i)
 
           if(is(value,"atomic"))
-             value <- lapply(1:kll,
+             value <- lapply(seq_len(kll),
                              function(y) data.frame(matrix(
                                          rep(value, length( i[[kl0[y]]])*length(j)),
                                          length(i[[kl0[y]]]),
@@ -70,7 +73,7 @@
                 value <- lapply(kl0,function(y) value)
 
           zl <- x at data
-          for(kk in 1:kll)
+          for(kk in seq_len(kll))
                  {z <- zl[[kl0[kk]]]
                   z[c(unlist(i[[kl0[kk]]])),j] <- value[kk]
                   zl[[kl0[kk]]] <- z

Modified: branches/distr-2.0/pkg/distrSim/man/subsetting-methods.Rd
===================================================================
--- branches/distr-2.0/pkg/distrSim/man/subsetting-methods.Rd	2008-05-30 12:56:51 UTC (rev 167)
+++ branches/distr-2.0/pkg/distrSim/man/subsetting-methods.Rd	2008-06-03 10:42:54 UTC (rev 168)
@@ -8,10 +8,8 @@
 \description{Operators acting on \code{SeqDataFrames} objects to extract
      or replace parts.}
 \usage{
-## "["(x,i,j,k, drop = FALSE) # is: x[i,j,k, drop = FALSE]
 \S4method{[}{SeqDataFrames}(x, i, j, k, drop = FALSE)
 
-## "[<-"(x,i,j,k, value)      # is: x[i,j,k] <- value
 \S4method{[}{SeqDataFrames}(x, i, j, k) <- value
 }
 \arguments{
@@ -34,15 +32,14 @@
 
 \value{again an object of class \code{SeqDataFrames} with the prescribed indices / values}
 \seealso{\code{\link[base]{"["}}}
-\keyword{methods}
 \examples{
 s0 <- matrix(1:6,3,2)
 d0 <- data.frame(s0)
 d1 <- data.frame(s0 + 3)
-SF <- seqDataFrames(d0, d1)
+SF <- SeqDataFrames(d0, d1)
 SF[1,2,1]
-
 }
+\keyword{methods}
 \concept{subsetting}
 \concept{indexing}
 \concept{accessor function}



More information about the Distr-commits mailing list