[R] Change of parsing parameters to functions between 0.63.1 and 0.63.3 ?
Athula Herath
Athula.Herath at ogs.co.uk
Wed Mar 24 17:44:38 CET 1999
Hi,
I wonder whether the mechanism of parsing parameters to functions has
changed between 0.63.1 and 0.63.3? The following code yeils different
results in R 0.63.1 (Version 0.63.1 (Dec 5, 1998)) and R 0.63.3.
cave<-function(x,a,b)
{
return(c(mean(x[a],na.rm=T),mean(x[b],na.rm=T)))
}
datx <- data.frame(rbind(c(1,2,3,4),c(4,5,6,7)))
names(datx)<-c("A","B","C","D")
f1<-c("A","C")
f2<-c("B","D")
t1<-apply(datx,1,cave,f1,f2)
R 0.63.1 Result:
> t1
1 2
[1,] 2 5
[2,] 3 6
R 0.63.3 Result:
> t1
1 2
[1,] NaN NaN
[2,] NaN NaN
If I include a
cat("x[a]->",a,"x[b]->",b,"\n")
in the function (cave)
R 0.63.1 shows the
x[a]-> 1 3 x[b]-> 2 4
x[a]-> 4 6 x[b]-> 5 7
Whereas in R 0.63.3 the result is :
x[a]-> NA NA x[b]-> NA NA
x[a]-> NA NA x[b]-> NA NA
Obviously, something is not right. I have verified this in both Unix
(Solaris, Linux) and also on WinNT
However, R Version
Version 0.64.0 Unstable (February 4, 1999)
Reports a similar behaviour to Version 0.63.1 : i.e. giving me the
correct results.
Many Thanks,
Athula
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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