[R] Matrix package transpose

Douglas Bates bates at stat.wisc.edu
Wed Apr 20 20:18:10 CEST 2011


On Wed, Apr 20, 2011 at 8:37 AM, Tobias Abenius
<tobias.abenius at chalmers.se> wrote:

> Since I installed R 2.13 I cannot use the transpose method "t" on sparse
> matrices inside my package. Outside the package works. Is there something
> new that I have to import methods? Can I then import everything from the
> Matrix package? The problem is that R tries to use t.default which of course
> doesn't work.

As the tag line on each message says:

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Please provide an example.  It will also help to include the output of

sessionInfo()

so we can determine exactly which version of R and the Matrix package
you are using on what platform.  Also try

> find("t")
[1] "package:Matrix" "package:base"

to see which version of "t" is the first on the search path.

It seems to still be  working for me, but "outside the package".

> library(Matrix)
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':

    det

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] Matrix_0.9996875-0 lattice_0.19-17

loaded via a namespace (and not attached):
[1] grid_2.13.0
> example(spMatrix)
... output omitted
> A
10 x 20 sparse Matrix of class "dgTMatrix"

 [1,] . 7 . . .  .  .  .  .  . . . . . . . . . . .
 [2,] . . . . .  .  .  .  .  . . . . . . . . . . .
 [3,] . . . . .  .  .  . 14  . . . . . . . . . . .
 [4,] . . . . . 21  .  .  .  . . . . . . . . . . .
 [5,] . . . . .  . 28  .  .  . . . . . . . . . . .
 [6,] . . . . .  .  . 35  .  . . . . . . . . . . .
 [7,] . . . . .  .  .  . 42  . . . . . . . . . . .
 [8,] . . . . .  .  .  .  . 49 . . . . . . . . . .
 [9,] . . . . .  .  .  .  .  . . . . . . . . . . .
[10,] . . . . .  .  .  .  .  . . . . . . . . . . .
> t(A)
20 x 10 sparse Matrix of class "dgTMatrix"

 [1,] . .  .  .  .  .  .  . . .
 [2,] 7 .  .  .  .  .  .  . . .
 [3,] . .  .  .  .  .  .  . . .
 [4,] . .  .  .  .  .  .  . . .
 [5,] . .  .  .  .  .  .  . . .
 [6,] . .  . 21  .  .  .  . . .
 [7,] . .  .  . 28  .  .  . . .
 [8,] . .  .  .  . 35  .  . . .
 [9,] . . 14  .  .  . 42  . . .
[10,] . .  .  .  .  .  . 49 . .
[11,] . .  .  .  .  .  .  . . .
[12,] . .  .  .  .  .  .  . . .
[13,] . .  .  .  .  .  .  . . .
[14,] . .  .  .  .  .  .  . . .
[15,] . .  .  .  .  .  .  . . .
[16,] . .  .  .  .  .  .  . . .
[17,] . .  .  .  .  .  .  . . .
[18,] . .  .  .  .  .  .  . . .
[19,] . .  .  .  .  .  .  . . .
[20,] . .  .  .  .  .  .  . . .



More information about the R-help mailing list