[R] assignment function
Peter Dalgaard BSA
p.dalgaard at pubhealth.ku.dk
Wed Feb 14 11:28:06 CET 2001
Christian Hoffmann <christian.hoffmann at wsl.ch> writes:
> Hi,
>
> I am trying to create the assignment function:
> "substring<-" <- function(text, first, last=100000, sub) {
....
> Checking
> > x <- 'this string'
> > substring(x, 3, 4) <- 'IS'
>
> will not result in
> > x [1] "thIS string"
>
> but will cry
> Error in substr<-(*tmp*, 3, 4, value = "IS") :
> unused argument(s) (value ...)
>
> A cat(is.character(first),"\n") after the first line will not even be
> executed.
For reasons that I have forgotten, the value of an assignment function
is always passed using an argument called "value", so try changing
"sub" to "value".
(I haven't *completely* forgotten the reason. It is something with
assignment functions like "[<-.data.frame" taking a variable number of
arguments.)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list