From p.dalgaard at biostat.ku.dk  Thu Feb 24 16:43:40 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Thu Feb 24 16:49:17 2005
Subject: [Rd] bug report for as.function (PR#7702)
In-Reply-To: <20050224145913.A7774B275@slim.kubism.ku.dk>
References: <20050224145913.A7774B275@slim.kubism.ku.dk>
Message-ID: <x2u0o20xqr.fsf@biostat.ku.dk>

becker@kfs.oeaw.ac.at writes:

> Hi,
> 
> I got the following message in R:
> Error in as.function.default(pdfs[1]) : invalid body argument for "function"
> Should NEVER happen; please bug.report() [mkCLOSXP]

Actually, I think that the only bug here is in the error message
(which presumably predates as.function()). If you can perform
arbitrary voodo and try to convert it into a function, then of course
you can also end up with an invalid body.
 
> Operating System: Windows XP (SP2)
> R version: R-2.0.1
> Code causing error follows:
> 
> # create two probability density functions for mixtures of normal 
> distibutions
> fmix1 <- function(x) {dnorm(x, mean=4, sd=2) * 0.5 + dnorm(x, mean=7, 
> sd=1) * 0.5}
> fmix2 <- function(x) {dnorm(x, mean=3, sd=1) * 0.4 + dnorm(x, mean=6, 
> sd=2) * 0.6}
> 
> # put them together
> pdfs <- c(fmix1, fmix2)
> 
> # perhaps this is not as it was intended but it leads to the bug.report 
> message
> as.function(pdfs[1])
> 
> Meanwhile I solved this problem otherwise.
> Hope this helps.
> Timo
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
   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


[Rd] bug report for as.function (PR#7702)
Peter Dalgaard