SCM

SCM Repository

[matrix] Diff of /pkg/R/Matrix.R
ViewVC logotype

Diff of /pkg/R/Matrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 874, Sat Aug 27 21:27:51 2005 UTC revision 875, Sat Aug 27 21:29:21 2005 UTC
# Line 102  Line 102 
102  ### Subsetting "["  and  ### Subsetting "["  and
103  ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":  ### SubAssign  "[<-" : The "missing" cases can be dealt with here, "at the top":
104    
105    ## Using "vector" for indices should allow
106    ## integer (numeric), logical, or character (names!) indices :
107    
108  ## "x[]":  ## "x[]":
109  setMethod("[", signature(x = "Matrix",  setMethod("[", signature(x = "Matrix",
110                           i = "missing", j = "missing", drop = "ANY"),                           i = "missing", j = "missing", drop = "ANY"),
# Line 109  Line 112 
112  ## missing 'drop' --> 'drop = TRUE'  ## missing 'drop' --> 'drop = TRUE'
113  ##                     -----------  ##                     -----------
114  ## select rows  ## select rows
115  setMethod("[", signature(x = "Matrix", i = "numeric", j = "missing",  setMethod("[", signature(x = "Matrix", i = "vector", j = "missing",
116                           drop = "missing"),                           drop = "missing"),
117            function(x,i,j, drop) callGeneric(x, i=i, drop= TRUE))            function(x,i,j, drop) callGeneric(x, i=i, drop= TRUE))
118  ## select columns  ## select columns
119  setMethod("[", signature(x = "Matrix", i = "missing", j = "numeric",  setMethod("[", signature(x = "Matrix", i = "missing", j = "vector",
120                           drop = "missing"),                           drop = "missing"),
121            function(x,i,j, drop) callGeneric(x, j=j, drop= TRUE))            function(x,i,j, drop) callGeneric(x, j=j, drop= TRUE))
122  setMethod("[", signature(x = "Matrix", i = "numeric", j = "numeric",  setMethod("[", signature(x = "Matrix", i = "vector", j = "vector",
123                           drop = "missing"),                           drop = "missing"),
124            function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE))            function(x,i,j, drop) callGeneric(x, i=i, j=j, drop= TRUE))
125    
126    ## bail out if any of (i,j,drop) is "non-sense"
127    setMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY", drop = "ANY"),
128              function(x,i,j, drop)
129              stop("invalid or not-yet-implemented 'Matrix' subsetting"))
130    
131  ## "FIXME:"  ## "FIXME:"
132  ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?  ## How can we get at   A[ ij ]  where ij is (i,j) 2-column matrix?
133  ##  and                A[ LL ]  where LL is a logical *vector*  ##  and                A[ LL ]  where LL is a logical *vector*
# Line 136  Line 144 
144  ## Otherwise (value is not "vector"): bail out  ## Otherwise (value is not "vector"): bail out
145  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",  setReplaceMethod("[", signature(x = "Matrix", i = "ANY", j = "ANY",
146                                  value = "ANY"),                                  value = "ANY"),
147            function (x, i, j, value) stop("RHS 'value' must be of class \"vector\""))            function (x, i, j, value)
148                     if(!is(value,"vector"))
149                     stop("RHS 'value' must be of class \"vector\"")
150                     else stop("unimplemented 'Matrix[<-' method"))
151    
152    
153    
154    

Legend:
Removed from v.874  
changed lines
  Added in v.875

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge