Re: [Rd] Compressing data for package builds

2012-08-17 Thread Uwe Ligges



On 17.08.2012 07:24, steven mosher wrote:

" R CMD build is how you preferably should be creating your package tar
ball, so you simply add the --resave-data argument to your already existing
R CMD build call which creates the tar ball from your source directory. So
can you elaborate on "doesn't do anything I can see"? In what sense? No
output? No compression? "

my tarball builds with   > R CDM build mattools

where mattools is the name of the package. and I get a warning on R CMD
check.

Things I tried

R CMD build --resave-data
R CMD build mattools --resave-data
R CMD build --resave-data mattools

The first does nothing, the second fails on unknown options and the third
fails on unknown options. So I  found the help for R CMD

Now that I figured out how to display help for  R CMD build  I see that

--resave-data   must include a specification of the type of compression

--resave-data="best"   for example

I ran that.  and got the same error indicating that the   rda file had not
been compressed.

  checking data for non-ASCII characters ... OK
* checking data for ASCII and uncompressed saves ... WARNING
   Warning: large data file(s) saved inefficiently:
 size ASCII compress
   zagoskin.rda 137Kb FALSE none

   Note: significantly better compression could be obtained
 by using R CMD build --resave-data
old_size new_size compress
   modpoll.rda 124Kb 78Kb   xz
   zagoskin.rda137Kb  6Kbbzip2

Building under windows so I wonder if I am missing a system file required
to do the compression.




Are you checking the tarball (as recommended) or the source dir? The 
compressed versions are in the tarball. The source dir is not changed.


Uwe Liges








On Thu, Aug 16, 2012 at 5:48 PM, Simon Urbanek
wrote:



On Aug 16, 2012, at 5:08 PM, steven mosher wrote:


Hi,

I have two  .rda files that I need to include in a package.  I've placed
them both in a data directory
after  save()  the are around  150Kb  each.

When I try to check the package I get the following warning

Warning: large data file(s) saved inefficiently:
size ASCII compress
  zagoskin.rda 137Kb FALSE none

  Note: significantly better compression could be obtained
by using R CMD build --resave-data
   old_size new_size compress
  modpoll.rda 124Kb 78Kb   xz
  zagoskin.rda137Kb  6Kbbzip2

Both of these files modpoll.rda and zagoskin.rda  have already been
compressed from megabytes down to Kb.

Also,, the  instructions"R CMD build --resave-data"  doesnt do

anything

that I can see so I must be using it wrong.


R CMD build is how you preferably should be creating your package tar
ball, so you simply add the --resave-data argument to your already existing
R CMD build call which creates the tar ball from your source directory. So
can you elaborate on "doesn't do anything I can see"? In what sense? No
output? No compression?

Cheers,
Simon



Is there a piece of the puzzle I am missing or instructions better than
these: I tried  LazyDataCompression and my
data.rdb is 90Kb.

"Package *tools* has a couple of functions to help with data images:
checkRdaFiles reports on the way the image was saved, and resaveRdaFiles

will

re-save with a different type of compression, including choosing the best
type for that particular image.

Some packages using ŒLazyData‚ will benefit from using a form of
compression other than gzip in the installed lazy-loading database. This
can be selected by the --data-compress option to R CMD INSTALL or by

using

the ŒLazyDataCompression‚ field in the DESCRIPTION file. Useful values

are

bzip2, xz and the default, gzip. The only way to discover which is best

is

to try them all and look at the size of the pkgname/data/Rdata.rdb file."

   [[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel





[[alternative HTML version deleted]]



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Cule, Erika
I have written an R package which contains C source code (in the directory 
pkg/src). 

Only a subset of the functions in the pkg/R directory contain a .C() call to 
the functions in the pkg/src directory. The rest of the package will still work 
and be useful without the functions containing a .C() call.

To compile the code in pkg/src requires the GSL library. This is detailed in 
the SystemRequirements line of the DESCRIPTION file and the Makevars file 
directs the compiler to LIB_GSL.

At what stage will installation fail for the end user if they don't have GSL 
installed? 

I have used Autoconf and configure, following the example in 1.2 of "Writing R 
Extensions" and the configure.ac file in the R package gsl, to detect whether 
the GSL library is installed on the computer and disable the R functions if the 
GSL library is not found (by using a TRUE/FALSE pattern substitution, as in the 
example in "Writing R Extensions"). If GSL is not available, will the package 
now install on another users machine with these functions disabled? Or upon 
installation will the installer try to install the code in pkg/src and fail 
because the libraries are not available?

Is there a practical way to test this? Both of the computers I have access to 
have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
HAVE_GSL=FALSE (although in the latter case the corresponding R functions are 
disabled). 

I hope that this is clear, and am happy to post my code if it would be useful.

Many thanks in advance.

Erika

---

Erika Cule
PhD student in Statistical Genetics
Imperial College London
Department of Epidemiology and Public Health
erika.cul...@imperial.ac.uk
http://occamstypewriter.org/erikacule/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Uwe Ligges



On 17.08.2012 11:11, Cule, Erika wrote:

I have written an R package which contains C source code (in the directory 
pkg/src).

Only a subset of the functions in the pkg/R directory contain a .C() call to 
the functions in the pkg/src directory. The rest of the package will still work 
and be useful without the functions containing a .C() call.

To compile the code in pkg/src requires the GSL library. This is detailed in 
the SystemRequirements line of the DESCRIPTION file and the Makevars file 
directs the compiler to LIB_GSL.

At what stage will installation fail for the end user if they don't have GSL 
installed?

I have used Autoconf and configure, following the example in 1.2 of "Writing R 
Extensions" and the configure.ac file in the R package gsl, to detect whether the GSL library 
is installed on the computer and disable the R functions if the GSL library is not found (by using 
a TRUE/FALSE pattern substitution, as in the example in "Writing R Extensions"). If GSL 
is not available, will the package now install on another users machine with these functions 
disabled? Or upon installation will the installer try to install the code in pkg/src and fail 
because the libraries are not available?


Yes, you have to work around the installation steps that compile and 
link your C sources and then the call to dynload the shared library in R.


It is porbably easier to use the gsl library via the gsl package, given 
it ptovides the gsl functionality you are using. In that case, you just 
need to suggest the gsl package an load it for the one function on 
demand only.


Best,
Uwe ligges



Is there a practical way to test this? Both of the computers I have access to 
have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
HAVE_GSL=FALSE (although in the latter case the corresponding R functions are 
disabled).

I hope that this is clear, and am happy to post my code if it would be useful.

Many thanks in advance.

Erika

---

Erika Cule
PhD student in Statistical Genetics
Imperial College London
Department of Epidemiology and Public Health
erika.cul...@imperial.ac.uk
http://occamstypewriter.org/erikacule/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Cule, Erika
Thanks Uwe

I am not quite sure I understand.

To clarify, do you mean writing my R functions as something like:

functionRequiringGsl <- function(arg1, arg2) 
{
if(require(gsl))
{
## Some functions that use GSL 
## called using .C()
} else {
stop("GSL not available")
}
}

If so, I still don't understand what happens when I compile the package if GSL 
is not installed on the computer, as there will still be C code in the src 
directory.

Thanks again

Erika


On 17 Aug 2012, at 12:35, Uwe Ligges wrote:

> 
> 
> On 17.08.2012 11:11, Cule, Erika wrote:
>> I have written an R package which contains C source code (in the directory 
>> pkg/src).
>> 
>> Only a subset of the functions in the pkg/R directory contain a .C() call to 
>> the functions in the pkg/src directory. The rest of the package will still 
>> work and be useful without the functions containing a .C() call.
>> 
>> To compile the code in pkg/src requires the GSL library. This is detailed in 
>> the SystemRequirements line of the DESCRIPTION file and the Makevars file 
>> directs the compiler to LIB_GSL.
>> 
>> At what stage will installation fail for the end user if they don't have GSL 
>> installed?
>> 
>> I have used Autoconf and configure, following the example in 1.2 of "Writing 
>> R Extensions" and the configure.ac file in the R package gsl, to detect 
>> whether the GSL library is installed on the computer and disable the R 
>> functions if the GSL library is not found (by using a TRUE/FALSE pattern 
>> substitution, as in the example in "Writing R Extensions"). If GSL is not 
>> available, will the package now install on another users machine with these 
>> functions disabled? Or upon installation will the installer try to install 
>> the code in pkg/src and fail because the libraries are not available?
> 
> Yes, you have to work around the installation steps that compile and link 
> your C sources and then the call to dynload the shared library in R.
> 
> It is porbably easier to use the gsl library via the gsl package, given it 
> ptovides the gsl functionality you are using. In that case, you just need to 
> suggest the gsl package an load it for the one function on demand only.
> 
> Best,
> Uwe ligges
> 
> 
>> Is there a practical way to test this? Both of the computers I have access 
>> to have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
>> HAVE_GSL=FALSE (although in the latter case the corresponding R functions 
>> are disabled).
>> 
>> I hope that this is clear, and am happy to post my code if it would be 
>> useful.
>> 
>> Many thanks in advance.
>> 
>> Erika
>> 
>> ---
>> 
>> Erika Cule
>> PhD student in Statistical Genetics
>> Imperial College London
>> Department of Epidemiology and Public Health
>> erika.cul...@imperial.ac.uk
>> http://occamstypewriter.org/erikacule/
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Uwe Ligges



On 17.08.2012 13:44, Cule, Erika wrote:

Thanks Uwe

I am not quite sure I understand.

To clarify, do you mean writing my R functions as something like:

functionRequiringGsl <- function(arg1, arg2)
{
if(require(gsl))
{
## Some functions that use GSL
## called using .C()
} else {
stop("GSL not available")
}
}

If so, I still don't understand what happens when I compile the package if GSL 
is not installed on the computer, as there will still be C code in the src 
directory.


Yes, I meant such a function. If GSL is not available, this function 
will give an ERROR, but the rest of the package works.


Uwe Ligges



Thanks again

Erika


On 17 Aug 2012, at 12:35, Uwe Ligges wrote:




On 17.08.2012 11:11, Cule, Erika wrote:

I have written an R package which contains C source code (in the directory 
pkg/src).

Only a subset of the functions in the pkg/R directory contain a .C() call to 
the functions in the pkg/src directory. The rest of the package will still work 
and be useful without the functions containing a .C() call.

To compile the code in pkg/src requires the GSL library. This is detailed in 
the SystemRequirements line of the DESCRIPTION file and the Makevars file 
directs the compiler to LIB_GSL.

At what stage will installation fail for the end user if they don't have GSL 
installed?

I have used Autoconf and configure, following the example in 1.2 of "Writing R 
Extensions" and the configure.ac file in the R package gsl, to detect whether the GSL library 
is installed on the computer and disable the R functions if the GSL library is not found (by using 
a TRUE/FALSE pattern substitution, as in the example in "Writing R Extensions"). If GSL 
is not available, will the package now install on another users machine with these functions 
disabled? Or upon installation will the installer try to install the code in pkg/src and fail 
because the libraries are not available?


Yes, you have to work around the installation steps that compile and link your 
C sources and then the call to dynload the shared library in R.

It is porbably easier to use the gsl library via the gsl package, given it 
ptovides the gsl functionality you are using. In that case, you just need to 
suggest the gsl package an load it for the one function on demand only.

Best,
Uwe ligges



Is there a practical way to test this? Both of the computers I have access to 
have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
HAVE_GSL=FALSE (although in the latter case the corresponding R functions are 
disabled).

I hope that this is clear, and am happy to post my code if it would be useful.

Many thanks in advance.

Erika

---

Erika Cule
PhD student in Statistical Genetics
Imperial College London
Department of Epidemiology and Public Health
erika.cul...@imperial.ac.uk
http://occamstypewriter.org/erikacule/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel





__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Cule, Erika
But will package compilation fail if GSL is not installed? 

(There are files in the src directory that are needed for the code to run)

On 17 Aug 2012, at 12:47, Uwe Ligges wrote:

> 
> 
> On 17.08.2012 13:44, Cule, Erika wrote:
>> Thanks Uwe
>> 
>> I am not quite sure I understand.
>> 
>> To clarify, do you mean writing my R functions as something like:
>> 
>> functionRequiringGsl <- function(arg1, arg2)
>> {
>>  if(require(gsl))
>>  {
>>  ## Some functions that use GSL
>>  ## called using .C()
>>  } else {
>>  stop("GSL not available")
>>  }
>> }
>> 
>> If so, I still don't understand what happens when I compile the package if 
>> GSL is not installed on the computer, as there will still be C code in the 
>> src directory.
> 
> Yes, I meant such a function. If GSL is not available, this function will 
> give an ERROR, but the rest of the package works.
> 
> Uwe Ligges
> 
> 
>> Thanks again
>> 
>> Erika
>> 
>> 
>> On 17 Aug 2012, at 12:35, Uwe Ligges wrote:
>> 
>>> 
>>> 
>>> On 17.08.2012 11:11, Cule, Erika wrote:
 I have written an R package which contains C source code (in the directory 
 pkg/src).
 
 Only a subset of the functions in the pkg/R directory contain a .C() call 
 to the functions in the pkg/src directory. The rest of the package will 
 still work and be useful without the functions containing a .C() call.
 
 To compile the code in pkg/src requires the GSL library. This is detailed 
 in the SystemRequirements line of the DESCRIPTION file and the Makevars 
 file directs the compiler to LIB_GSL.
 
 At what stage will installation fail for the end user if they don't have 
 GSL installed?
 
 I have used Autoconf and configure, following the example in 1.2 of 
 "Writing R Extensions" and the configure.ac file in the R package gsl, to 
 detect whether the GSL library is installed on the computer and disable 
 the R functions if the GSL library is not found (by using a TRUE/FALSE 
 pattern substitution, as in the example in "Writing R Extensions"). If GSL 
 is not available, will the package now install on another users machine 
 with these functions disabled? Or upon installation will the installer try 
 to install the code in pkg/src and fail because the libraries are not 
 available?
>>> 
>>> Yes, you have to work around the installation steps that compile and link 
>>> your C sources and then the call to dynload the shared library in R.
>>> 
>>> It is porbably easier to use the gsl library via the gsl package, given it 
>>> ptovides the gsl functionality you are using. In that case, you just need 
>>> to suggest the gsl package an load it for the one function on demand only.
>>> 
>>> Best,
>>> Uwe ligges
>>> 
>>> 
 Is there a practical way to test this? Both of the computers I have access 
 to have GSL available, and installation works whether I set HAVE_GSL=TRUE 
 or HAVE_GSL=FALSE (although in the latter case the corresponding R 
 functions are disabled).
 
 I hope that this is clear, and am happy to post my code if it would be 
 useful.
 
 Many thanks in advance.
 
 Erika
 
 ---
 
 Erika Cule
 PhD student in Statistical Genetics
 Imperial College London
 Department of Epidemiology and Public Health
 erika.cul...@imperial.ac.uk
 http://occamstypewriter.org/erikacule/
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
 
>> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Uwe Ligges



On 17.08.2012 13:49, Cule, Erika wrote:

But will package compilation fail if GSL is not installed?


No, not this way: since the gsl package can be in the Suggests now 
(rather than the Depends).


Best,
Uwe Ligges




(There are files in the src directory that are needed for the code to run)

On 17 Aug 2012, at 12:47, Uwe Ligges wrote:




On 17.08.2012 13:44, Cule, Erika wrote:

Thanks Uwe

I am not quite sure I understand.

To clarify, do you mean writing my R functions as something like:

functionRequiringGsl <- function(arg1, arg2)
{
if(require(gsl))
{
## Some functions that use GSL
## called using .C()
} else {
stop("GSL not available")
}
}

If so, I still don't understand what happens when I compile the package if GSL 
is not installed on the computer, as there will still be C code in the src 
directory.


Yes, I meant such a function. If GSL is not available, this function will give 
an ERROR, but the rest of the package works.

Uwe Ligges



Thanks again

Erika


On 17 Aug 2012, at 12:35, Uwe Ligges wrote:




On 17.08.2012 11:11, Cule, Erika wrote:

I have written an R package which contains C source code (in the directory 
pkg/src).

Only a subset of the functions in the pkg/R directory contain a .C() call to 
the functions in the pkg/src directory. The rest of the package will still work 
and be useful without the functions containing a .C() call.

To compile the code in pkg/src requires the GSL library. This is detailed in 
the SystemRequirements line of the DESCRIPTION file and the Makevars file 
directs the compiler to LIB_GSL.

At what stage will installation fail for the end user if they don't have GSL 
installed?

I have used Autoconf and configure, following the example in 1.2 of "Writing R 
Extensions" and the configure.ac file in the R package gsl, to detect whether the GSL library 
is installed on the computer and disable the R functions if the GSL library is not found (by using 
a TRUE/FALSE pattern substitution, as in the example in "Writing R Extensions"). If GSL 
is not available, will the package now install on another users machine with these functions 
disabled? Or upon installation will the installer try to install the code in pkg/src and fail 
because the libraries are not available?


Yes, you have to work around the installation steps that compile and link your 
C sources and then the call to dynload the shared library in R.

It is porbably easier to use the gsl library via the gsl package, given it 
ptovides the gsl functionality you are using. In that case, you just need to 
suggest the gsl package an load it for the one function on demand only.

Best,
Uwe ligges



Is there a practical way to test this? Both of the computers I have access to 
have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
HAVE_GSL=FALSE (although in the latter case the corresponding R functions are 
disabled).

I hope that this is clear, and am happy to post my code if it would be useful.

Many thanks in advance.

Erika

---

Erika Cule
PhD student in Statistical Genetics
Imperial College London
Department of Epidemiology and Public Health
erika.cul...@imperial.ac.uk
http://occamstypewriter.org/erikacule/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel







__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Prof Brian Ripley
What you have not told us is your platform (but it was Mac OS X the 
other day).  The answers are different if you are doing source installs 
or binary installs and if the latter, by platform.


If you are doing source installs on the machine to be used, configure 
should adjust the install accordingly.


If you transfer a binary install done without GSL to another machine 
with GSL, the installed package will have the GSL functions disabled.


If you transfer a binary install done with GSL to a machine without, it 
depends.  As both Windows and OS X binary builds use a static libgsl, 
they will be fine and the package will have working GSL-based functions. 
 In other cases with dynamic linking the package may fail to load or 
attempts to use the GSL-based functions may crash the R session.




On 17/08/2012 10:11, Cule, Erika wrote:

I have written an R package which contains C source code (in the directory 
pkg/src).

Only a subset of the functions in the pkg/R directory contain a .C() call to 
the functions in the pkg/src directory. The rest of the package will still work 
and be useful without the functions containing a .C() call.

To compile the code in pkg/src requires the GSL library. This is detailed in 
the SystemRequirements line of the DESCRIPTION file and the Makevars file 
directs the compiler to LIB_GSL.

At what stage will installation fail for the end user if they don't have GSL 
installed?

I have used Autoconf and configure, following the example in 1.2 of "Writing R 
Extensions" and the configure.ac file in the R package gsl, to detect whether the GSL library 
is installed on the computer and disable the R functions if the GSL library is not found (by using 
a TRUE/FALSE pattern substitution, as in the example in "Writing R Extensions"). If GSL 
is not available, will the package now install on another users machine with these functions 
disabled? Or upon installation will the installer try to install the code in pkg/src and fail 
because the libraries are not available?

Is there a practical way to test this? Both of the computers I have access to 
have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
HAVE_GSL=FALSE (although in the latter case the corresponding R functions are 
disabled).

I hope that this is clear, and am happy to post my code if it would be useful.

Many thanks in advance.

Erika

---

Erika Cule
PhD student in Statistical Genetics
Imperial College London
Department of Epidemiology and Public Health
erika.cul...@imperial.ac.uk
http://occamstypewriter.org/erikacule/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Dirk Eddelbuettel

On 17 August 2012 at 11:44, Cule, Erika wrote:
| If so, I still don't understand what happens when I compile the package if 
GSL is not installed on the computer, as there will still be C code in the src 
directory.

That is precisely the use case for autoconf et al.

You test if something (here GSL) is available (and there are macros and
examples for in many places) and then define a header file variable such as
I_HAVE_FOUND_GSL as 1 or 0, say.  In your C code, you then use something like

   #if I_HAVE_FOUND_GSL == 1

   some code

   #endif 

Now your code compiles in both cases.

Alternatively, you just depend on the GSL. Many packages on CRAN do, and the
Windows build infrastructure provides it.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Cule, Erika
Ah I see! Had not thought of that solution.

(This is the first time I have tried to use autoconf and configure)

Many thanks.

Erika

On 17 Aug 2012, at 13:04, Dirk Eddelbuettel wrote:

> 
> On 17 August 2012 at 11:44, Cule, Erika wrote:
> | If so, I still don't understand what happens when I compile the package if 
> GSL is not installed on the computer, as there will still be C code in the 
> src directory.
> 
> That is precisely the use case for autoconf et al.
> 
> You test if something (here GSL) is available (and there are macros and
> examples for in many places) and then define a header file variable such as
> I_HAVE_FOUND_GSL as 1 or 0, say.  In your C code, you then use something like
> 
>   #if I_HAVE_FOUND_GSL == 1
> 
>   some code
> 
>   #endif 
> 
> Now your code compiles in both cases.
> 
> Alternatively, you just depend on the GSL. Many packages on CRAN do, and the
> Windows build infrastructure provides it.
> 
> Dirk
> 
> -- 
> Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com  

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R package compilation: files in src directory should be ignored if C library is not available

2012-08-17 Thread Cule, Erika
Thank you, that is very helpful.

On 17 Aug 2012, at 12:58, Prof Brian Ripley wrote:

> What you have not told us is your platform (but it was Mac OS X the other 
> day).  The answers are different if you are doing source installs or binary 
> installs and if the latter, by platform.

Apologies for omitting to tell you the platform. I didn't know that it makes a 
difference, and was thinking about how to make the code portable for submission 
to CRAN.

> 
> If you are doing source installs on the machine to be used, configure should 
> adjust the install accordingly.

Dirk just told me how to do that in another message. 

> 
> If you transfer a binary install done without GSL to another machine with 
> GSL, the installed package will have the GSL functions disabled.
> 
> If you transfer a binary install done with GSL to a machine without, it 
> depends.  As both Windows and OS X binary builds use a static libgsl, they 
> will be fine and the package will have working GSL-based functions.  In other 
> cases with dynamic linking the package may fail to load or attempts to use 
> the GSL-based functions may crash the R session.
> 

That is useful to know because I was wondering how I was going to make my code 
portable for Windows users. As I understand, when R binaries are built for 
windows GSL is on the computer that builds them so Windows binaries should 
work. (Dirk just confirmed this.) 

Many thanks to Prof Ripley, Dirk Eddelbuettel and Uwe Ligges for helping me 
with this. 

Erika

> 
> 
> On 17/08/2012 10:11, Cule, Erika wrote:
>> I have written an R package which contains C source code (in the directory 
>> pkg/src).
>> 
>> Only a subset of the functions in the pkg/R directory contain a .C() call to 
>> the functions in the pkg/src directory. The rest of the package will still 
>> work and be useful without the functions containing a .C() call.
>> 
>> To compile the code in pkg/src requires the GSL library. This is detailed in 
>> the SystemRequirements line of the DESCRIPTION file and the Makevars file 
>> directs the compiler to LIB_GSL.
>> 
>> At what stage will installation fail for the end user if they don't have GSL 
>> installed?
>> 
>> I have used Autoconf and configure, following the example in 1.2 of "Writing 
>> R Extensions" and the configure.ac file in the R package gsl, to detect 
>> whether the GSL library is installed on the computer and disable the R 
>> functions if the GSL library is not found (by using a TRUE/FALSE pattern 
>> substitution, as in the example in "Writing R Extensions"). If GSL is not 
>> available, will the package now install on another users machine with these 
>> functions disabled? Or upon installation will the installer try to install 
>> the code in pkg/src and fail because the libraries are not available?
>> 
>> Is there a practical way to test this? Both of the computers I have access 
>> to have GSL available, and installation works whether I set HAVE_GSL=TRUE or 
>> HAVE_GSL=FALSE (although in the latter case the corresponding R functions 
>> are disabled).
>> 
>> I hope that this is clear, and am happy to post my code if it would be 
>> useful.
>> 
>> Many thanks in advance.
>> 
>> Erika
>> 
>> ---
>> 
>> Erika Cule
>> PhD student in Statistical Genetics
>> Imperial College London
>> Department of Epidemiology and Public Health
>> erika.cul...@imperial.ac.uk
>> http://occamstypewriter.org/erikacule/
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
> 
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] data() documentation ambiguous about loaded versus attached packages?

2012-08-17 Thread Martin Morgan

Under ?data

 package: a character vector giving the package(s) to look in for data
  sets, or 'NULL'.

  By default, all packages in the search path are used, then
  the 'data' subdirectory (if present) of the current working
  directory.

which I think is accurate -- packages have to be attached for their data 
to be found; being loaded (as when PkgB Imports: PkgA) is not 
sufficient. Later we have


 If 'lib.loc' and 'package' are both 'NULL' (the default), the data
 sets are searched for in all the currently loaded packages then in
 the 'data' directory (if any) of the current working directory.

which I think is incorrect ('currently attached packages') and

 If 'lib.loc = NULL' but 'package' is specified as a character
 vector, the specified package(s) are searched for first amongst
 loaded packages and then in the default library/ies (see
 '.libPaths').

which I'm unsure of -- probably 'amongst attached packages'.

FWIW most Bioconductor packages that use data() in function calls 
currently do so without specifying 'package', and without specifying an 
'envir' argument (hence overwriting user objects in the global environment).


> R.version.string
[1] "R Under development (unstable) (2012-08-17 r60296)"

Martin
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Compressing data for package builds

2012-08-17 Thread steven mosher
I believe that was my boneheaded error.. checking now.. Yup

Thanks guys!

On Fri, Aug 17, 2012 at 3:01 AM, Uwe Ligges  wrote:

>
>
> On 17.08.2012 07:24, steven mosher wrote:
>
>> " R CMD build is how you preferably should be creating your package tar
>> ball, so you simply add the --resave-data argument to your already
>> existing
>> R CMD build call which creates the tar ball from your source directory. So
>> can you elaborate on "doesn't do anything I can see"? In what sense? No
>> output? No compression? "
>>
>> my tarball builds with   > R CDM build mattools
>>
>> where mattools is the name of the package. and I get a warning on R CMD
>> check.
>>
>> Things I tried
>>
>> R CMD build --resave-data
>> R CMD build mattools --resave-data
>> R CMD build --resave-data mattools
>>
>> The first does nothing, the second fails on unknown options and the third
>> fails on unknown options. So I  found the help for R CMD
>>
>> Now that I figured out how to display help for  R CMD build  I see that
>>
>> --resave-data   must include a specification of the type of compression
>>
>> --resave-data="best"   for example
>>
>> I ran that.  and got the same error indicating that the   rda file had not
>> been compressed.
>>
>>   checking data for non-ASCII characters ... OK
>> * checking data for ASCII and uncompressed saves ... WARNING
>>Warning: large data file(s) saved inefficiently:
>>  size ASCII compress
>>zagoskin.rda 137Kb FALSE none
>>
>>Note: significantly better compression could be obtained
>>  by using R CMD build --resave-data
>> old_size new_size compress
>>modpoll.rda 124Kb 78Kb   xz
>>zagoskin.rda137Kb  6Kbbzip2
>>
>> Building under windows so I wonder if I am missing a system file required
>> to do the compression.
>>
>
>
>
> Are you checking the tarball (as recommended) or the source dir? The
> compressed versions are in the tarball. The source dir is not changed.
>
> Uwe Liges
>
>
>
>
>
>
>
>
>> On Thu, Aug 16, 2012 at 5:48 PM, Simon Urbanek
>> **wrote:
>>
>>
>>> On Aug 16, 2012, at 5:08 PM, steven mosher wrote:
>>>
>>>  Hi,

 I have two  .rda files that I need to include in a package.  I've placed
 them both in a data directory
 after  save()  the are around  150Kb  each.

 When I try to check the package I get the following warning

 Warning: large data file(s) saved inefficiently:
 size ASCII compress
   zagoskin.rda 137Kb FALSE none

   Note: significantly better compression could be obtained
 by using R CMD build --resave-data
old_size new_size compress
   modpoll.rda 124Kb 78Kb   xz
   zagoskin.rda137Kb  6Kbbzip2

 Both of these files modpoll.rda and zagoskin.rda  have already been
 compressed from megabytes down to Kb.

 Also,, the  instructions"R CMD build --resave-data"  doesnt do

>>> anything
>>>
 that I can see so I must be using it wrong.

>>>
>>> R CMD build is how you preferably should be creating your package tar
>>> ball, so you simply add the --resave-data argument to your already
>>> existing
>>> R CMD build call which creates the tar ball from your source directory.
>>> So
>>> can you elaborate on "doesn't do anything I can see"? In what sense? No
>>> output? No compression?
>>>
>>> Cheers,
>>> Simon
>>>
>>>
>>>  Is there a piece of the puzzle I am missing or instructions better than
 these: I tried  LazyDataCompression and my
 data.rdb is 90Kb.

 "Package *tools* has a couple of functions to help with data images:
 checkRdaFiles reports on the way the image was saved, and resaveRdaFiles

>>> will
>>>
 re-save with a different type of compression, including choosing the
 best
 type for that particular image.

 Some packages using ŒLazyData‚ will benefit from using a form of
 compression other than gzip in the installed lazy-loading database. This
 can be selected by the --data-compress option to R CMD INSTALL or by

>>> using
>>>
 the ŒLazyDataCompression‚ field in the DESCRIPTION file. Useful values

>>> are
>>>
 bzip2, xz and the default, gzip. The only way to discover which is best

>>> is
>>>
 to try them all and look at the size of the pkgname/data/Rdata.rdb
 file."

[[alternative HTML version deleted]]

 __**
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-devel

>>>
>>>
>>>
>> [[alternative HTML version deleted]]
>>
>>
>>
>> __**
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-devel
>>
>>

[[alternative HTML version deleted]]