From peter.ruckdeschel at web.de  Sun May  1 14:41:50 2016
From: peter.ruckdeschel at web.de (Peter Ruckdeschel)
Date: Sun, 1 May 2016 14:41:50 +0200
Subject: [Rd] Storage of byte code-compiled functions in sysdata.rda
In-Reply-To: <704D9B27-D7A7-4B46-A2F4-82E0582AC6B5@uiowa.edu>
References: <5725ED5B.20208@web.de>
	<704D9B27-D7A7-4B46-A2F4-82E0582AC6B5@uiowa.edu>
Message-ID: <5725F98E.5040609@web.de>

Thanks, Luke, for having a look to it.

Sure, I can give you some reproducible example -- even in two degrees of
completeness ;-): see below.

Thanks again, Peter

%-----------------------------------
(I) first example
%-----------------------------------
Just to reproduce the error, on r-devel, try:

install.packages("RobAStRDA")
require(RobAStRDA)
getFromNamespace(".RMXE", ns = "RobAStRDA")[["GEVFamily"]][["fun.N"]][[1]](1.3)

%-----------------------------------
(II) an example also giving the context
%-----------------------------------
For the "complete" story, not only the R-code needs to be given, but also the
preparation steps to produce the packages on the right R version;

so please follow steps (1)--(6) below; I am not 100% sure whether this already gives
you all information needed for this, but if not so please let me know.

(1) create a minimal R-package "InterpolTry"
      with byte-compilation on in the DESCRIPTION file
      and with stats::approxfun imported in the NAMESPACE file

(2) in an R session on R-devel do     

require(InterpolTry)
x <- 1:100
y <- 1:100
fun <- approxfun(x,y)
## revise the next line accordingly to your local settings
SrcRPathInterpolTry <- <path_to_(source-)R-folder_of_InterpolTry>
RdaFile <- file.path(SrcRPathInterpolTry, "sysdata.rda")
save(fun, file = RdaFile)
tools::resaveRdaFiles(RdaFile)

(3) re-build package InterpolTry and re-install it

(4) create a minimal R package "UseInterpolTry", again
      with byte-compilation on in the DESCRIPTION file
      and with stats::approxfun and package "InterpolTry"
      imported in the NAMESPACE file

(5) in the R folder of R package "UseInterpolTry" write a function
      useInterpolFct()  which goes like this

      useInterpolFct <- function(x){
               fun <- getFromNamespace("fun", ns = "InterpolTry")
               fun(x)
      }

     export this function in the namespace and create an .Rd file to it      

(6) (re-)build package "UseInterpolTry" and (re-)install it and try

require(UseInterpolTry)
useInterpolFct(5)

Steps (1)--(6) work with R-3.1.3, but no longer with R-devel.



Am 01.05.2016 um 14:12 schrieb Tierney, Luke:
> Can you provide a complete reproducible example?
>
> Sent from my iPhone
>
>> On May 1, 2016, at 6:51 AM, Peter Ruckdeschel <peter.ruckdeschel at web.de> wrote:
>>
>> Hi r-devels,
>>
>> we are seeing a new problem with our packages RobAStRDA (just new on CRAN, thanks
>> to Uwe and Kurt!) and RobExtremes (to be submitted).
>>
>> It must be something recent with the way you internally treat/store byte-code compiled
>> functions, as we have no problems with R-3.1.3, but do see an "Error in fct(x) : byte code
>> version mismatch" with R-devel SVNrev r70532.
>>
>> Background: 
>> Starting from several x-y grids, in the sysdata.rda file of RobAStRDA, we store the results 
>> of calls to approxfun/splinefun to these grids from within a session with pkg RobAStRDA 
>> require()d.  From pkg RobExtremes we then call these interpolating functions by means of 
>> a call (essentially) as:
>>
>> getFromNamespace(".RMXE", ns = "RobAStRDA")[["GEVFamily"]][["fun.N"]][[1]](1.3)
>>
>> upon which we get the announced "Error in fct(x) : byte code version mismatch" while the same 
>> code does work for R-3.1.3.
>>
>> The list element "fun.N" in the above call already accounts for a different behaviour for
>> pre R-3.0.0 (would have given "fun.O") and post R-3.0.0 ("fun.N") results of approxfun/
>> splinefun, but the interpolating functions in branch "fun.N" have been produced in
>> R-devel SVNrev r70532, so we would have expected our code getFromNamespace(.....) above to 
>> work in R-devel as well.
>>
>> Could you give us any hints how to
>>
>> (a) store the interpolating functions resulting from approxfun/splinefun in pkg RobAStRDA
>>    correctly in recent R-versions and
>> (b) call these functions in pkg RobExtremes ?
>>
>> We already did import stats::approxfun and stats::splinefun into the NAMESPACEs of pkgs
>> RobAStRDA and RobExtremes.
>>
>> Thanks for your help already,
>> Peter
>>
>>
>> ---
>> Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft.
>> https://www.avast.com/antivirus
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft.
https://www.avast.com/antivirus



[Rd] Storage of byte code-compiled functions in sysdata.rda
Peter Ruckdeschel