Full_Name: Alex Deckmyn Version: 1.5.1 OS: Linux Mandrake 7.0 Submission from: (NULL) (193.190.63.62) A short function in a library contains the complex number -2i : phihat <- function(x) { x+ (-2i) } If i read the source file with source("phihat") this works fine. If I include it as a function in a library and read it with library(test), the function is still read corectly, but when I print it out it shows as> phihatfunction (x) { x + (-0+2i) } Internally R still uses (-2i) though:> phihat(0)[1] 0-2i The problem only seems to occur when the function is part of a library. When I read the same function via source:> source("~/software/R-libs/test/R/test") > phihatfunction(x) { x+ (-2i) } Usually I work in emacs using ESS. When I edit the function phihat (Ctrl-C Ctrl-d) I get the bad representation and after reloading the function (ctrl-c ctrl-l) the function has changed. quite a dangerous bug, I think, though I admit my Linux version is quite old. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This looks like bug PR#1697 in the deparser. I've written a patch that fixes that case; I'll check out this one. On Wed, 3 Jul 2002 14:25:59 +0200 (MET DST), you wrote in message <200207031225.OAA08552@pubhealth.ku.dk>:>Full_Name: Alex Deckmyn >Version: 1.5.1 >OS: Linux Mandrake 7.0 >Submission from: (NULL) (193.190.63.62) > > >A short function in a library contains the complex number -2i : > >phihat <- function(x) > { >x+ (-2i) > } > > >If i read the source file with source("phihat") this works fine. If I include it >as > a function in a library and read it with library(test), the function is still >read corectly, but when I print it out it shows as > >> phihat >function (x) >{ > x + (-0+2i) >}The difference is that in the first case R keeps the source of the function (in attr(phihat,'source')). In the second case it deparses the internal representation. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._