From cgenolin at u-paris10.fr  Fri Sep 12 15:10:14 2014
From: cgenolin at u-paris10.fr (cgenolin)
Date: Fri, 12 Sep 2014 06:10:14 -0700 (PDT)
Subject: [Rd] Compatibility issues between Matrix and kml
Message-ID: <1410527414882-4696885.post@n4.nabble.com>

Hi the list,

I am the maintainer of the package kml. I quite often receive some email
about a specific bug. The answer is always the same, I tell people to remove
the package Matrix, and then kml works fine.

I wonder what my code is not compatible with the Matrix package. Here is a
(simplified) version of the kml code :

--- 8< ------------
library(longitudinalData)

setClass(Class="CLD", contains=c("LongData","ListPartition"))

myCld <- new("CLD",
        idAll=as.character(c(100,102,103,109,115,123)),
        idFewNA=as.character(c(100,102,103,109,115,123)),
        time=c(1,2,4,8,15), varNames="P",
        traj=matrix(c(1,2,3,1,4, 3,6,1,8,10, 1,2,1,3,2, 4,2,5,6,3,
4,3,4,4,4, 7,6,5,5,4),6),
        dimTraj=c(6,5), maxNA=3,  reverse=matrix(c(0,1),2,1)
)

setMethod("[",
     signature=signature(x="CLD", i="character", j="ANY",drop="ANY"),
     definition=function (x, i, j="missing", ..., drop = TRUE){
         x <- as(x, "LongData")
         return(x[i, j])
     }
)
# [1] "["

myCld["idAll"]
# [1] "100" "102" "103" "109" "115" "123"

--- 8< ---------------

This code works just fine, there is no error.

But if I load the package Matrix and I run the same code, I get:

--- 8< ----------------
library(Matrix)
library(longitudinalData)

setClass(Class="CLD", contains=c("LongData","ListPartition"))

myCld <- new("CLD",
        idAll=as.character(c(100,102,103,109,115,123)),
        idFewNA=as.character(c(100,102,103,109,115,123)),
        time=c(1,2,4,8,15), varNames="P",
        traj=matrix(c(1,2,3,1,4, 3,6,1,8,10, 1,2,1,3,2, 4,2,5,6,3,
4,3,4,4,4, 7,6,5,5,4),6),
        dimTraj=c(6,5), maxNA=3,  reverse=matrix(c(0,1),2,1)
)

setMethod("[",
     signature=signature(x="CLD", i="character", j="ANY",drop="ANY"),
     definition=function (x, i, j="missing", ..., drop = TRUE){
         x <- as(x, "LongData")
         return(x[i, j])
     }
)

# [1] "["

myCld["idAll"]
# Error in myCld["idAll"]:
#   Argument "j" is missing, with no default value
--- 8< ----------------

Any idea of what is going wrong?

Christophe




--
View this message in context: http://r.789695.n4.nabble.com/Compatibility-issues-between-Matrix-and-kml-tp4696885.html
Sent from the R devel mailing list archive at Nabble.com.



[Rd] Compatibility issues between Matrix and kml
cgenolin