This fairly harmless looking piece of code, which worked in
0.61 (and in S-PLUS) fails in 0.62.1.
R> "mcpar<-" <- function(x,mcpar) {attr(x,"mcpar") <- mcpar; x}
R> mcpar(x) <- c(1,100,1)
Error in mcpar<-(*tmp*, value = c(1, 100, 1)) : unused argument to function
The error message gives a hint about how to work around the problem -
just replace the argument "mcpar" with "value".
R> "mcpar<-" <- function(x,value) {attr(x,"mcpar") <- value; x}
R> mcpar(x) <- c(1,100,1)
R>
This breaks release 0.3-3 of my "coda" package, but I will fix it.
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
bug in functions of form "mcpar<-"
6 messages · Peter Dalgaard, Paul Gilbert, Martyn Plummer
Martyn Plummer <plummer@iarc.fr> writes:
This fairly harmless looking piece of code, which worked in
0.61 (and in S-PLUS) fails in 0.62.1.
R> "mcpar<-" <- function(x,mcpar) {attr(x,"mcpar") <- mcpar; x}
R> mcpar(x) <- c(1,100,1)
Error in mcpar<-(*tmp*, value = c(1, 100, 1)) : unused argument to function
The error message gives a hint about how to work around the problem -
just replace the argument "mcpar" with "value".
R> "mcpar<-" <- function(x,value) {attr(x,"mcpar") <- value; x}
R> mcpar(x) <- c(1,100,1)
R>
This breaks release 0.3-3 of my "coda" package, but I will fix it.
Martyn
Hmm. We had some pretty antisocial consequences from *not* using the value= form with John Chambers' [<-.data.frame code, which assumes that it is used that way in order to see whether i,j, or both are absent. So Splus is using value= on indexing operations only?
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I'm having the same problem without a clue to a work around. (Mind you, the work
around for mcpar wasn't so obvious to me.)
Paul Gilbert
____
R : Copyright 1998, The R Development Core Team
Version 0.62.1 (June 15, 1998)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "?license" or "?licence" for distribution details.
R is a collaborative project with many contributors.
Type "?contributors" for a list.
Type "demo()" for some demos, "help()" for on-line help, or
"help.start()" for a HTML browser interface to help.
search()
[1] ".GlobalEnv" "Autoloads" "package:base"
"tframe<-" <-function(x, tf)
{
attr(x, "tframe") <- tf
x
}
+ + + + > >
x <- 1:10 tframe(x) <- c(1,1000,1)
Error in tframe<-(*tmp*, value = c(1, 1000, 1)) : unused argument to function
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
The light came on. I was thinking the problem with mcpar was that the argument had the same name as the function, but it is that the argument must be called "value". If R is intended to be like this it seems like a pretty serious incompatibility with S (not to mention that I will have to make a lot of changes). Paul Gilbert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA wrote:
Hmm. We had some pretty antisocial consequences from *not* using the value= form with John Chambers' [<-.data.frame code, which assumes that it is used that way in order to see whether i,j, or both are absent. So Splus is using value= on indexing operations only?
Looks like it. As I said, my other example works in S-PLUS, but try
doing
the same thing with an assignment on an index and you get an error:
(This examples is obviously silly in order to distinguish it from the
default
indexing function).
S> "[<-.foo" <-
function(x,i,value){y<-unclass(x);y[i]<-value+1;class(y)<-"foo";y}
S> x <- 1:10
S> class(x) <- "foo"
S> x[1]<-100
S> x
[1] 101 2 3 4 5 6 7 8 9 10
attr(, "class"):
[1] "foo"
S> "[<-.foo" <-
function(x,i,bar){y<-unclass(x);y[i]<-bar+1;class(y)<-"foo";y}
S> x[1]<-200
Error in call to [<-.foo(): Argument value= not matched
Dumped
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
So Splus is using value= on indexing operations only?
Looks like it. As I said, my other example works in S-PLUS,
Definitely Splus does not in general require "value" as the name of the argument. I've changed about a dozen instances of this in my code. It turned out not to be as bad a job as I expected, debugging because of the one change I missed was the worst part. But everything was working fine in Splus. Paul Gilbert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._