[R] Sub-matrixes that are linked to the "Base matrix"

Friedrich gotisch at gmail.com
Mon Jan 18 02:36:15 CET 2010


Hello,

I'm am in the process of trying to port a RATS functions to R and have
the problem, that RATS allows for the creation of submatrixes that are
linked to their basematrix.

Basically it should work like this:

a = matrix(1:(4*3),4,3)
a
#      [,1] [,2] [,3]
# [1,]    1    5    9
# [2,]    2    6   10
# [3,]    3    7   11
# [4,]    4    8   12

# This of course doesnt work :)
b = submatrix(a,fromx=1,tox=2,fromy=1,toy=2)
b
#      [,1] [,2]
# [1,]    0   10
# [2,]    7   11
b[1,1] = 42
a[1,1]
# [1] 42

so changes in the sub-matrix propagate to the "base" matrix.

Does such a feature exist?

Thanks,



More information about the R-help mailing list