Re: [R-pkg-devel] Source code of an existing package

2016-08-10 Thread Holger Hoefling
Hi,

If you are interested in the source code of an entire package in its
original form - you can also download the .tar.gz version of the package
from CRAN. In a .tar.gz, you find the sources, unlike the .zip for windows,
which is already compiled.

If you are under windows, you can use a program such as 7-zip to unzip the
.tar.gz (which is mostly used on unix systems).

The R code of the package is in the R subfolder

In your case, the function boot.ci, is in

R/bootfuns.q

and starts in the latest version on line 859

Best

Holger

On Thu, Aug 11, 2016 at 3:42 AM, Marcelo Carvalho Fernandes <
mcf2...@gmail.com> wrote:

> Hi all!
>
> I am interested in seeing the source code of the boot.ci() function of
> the boot package.
>
> Is it possible to have such source code? How?
>
> Thanks in advance,
>
> ---
> Marcelo Carvalho Fernandes
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

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


Re: [R-pkg-devel] Source code of an existing package

2016-08-10 Thread Dirk Eddelbuettel

On 10 August 2016 at 22:14, Ben Bolker wrote:
| 
|  Easiest way:
| 
|   library(boot)
|   boot.ci
| 
| Alternatively, go to https://cran.r-project.org/package=boot ,
| download the tarball, unpack it, and look around in the R/ directory.

Uwe Ligges wrote an 'R Help Desk' piece in R News about this -- see pages 43
to 45 here:
   https://www.r-project.org/doc/Rnews/Rnews_2006-4.pdf

Dirk

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

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


Re: [R-pkg-devel] Source code of an existing package

2016-08-10 Thread Ben Bolker

 Easiest way:

  library(boot)
  boot.ci

Alternatively, go to https://cran.r-project.org/package=boot ,
download the tarball, unpack it, and look around in the R/ directory.

On 16-08-10 09:42 PM, Marcelo Carvalho Fernandes wrote:
> Hi all!
> 
> I am interested in seeing the source code of the boot.ci() function of the 
> boot package.
> 
> Is it possible to have such source code? How?
> 
> Thanks in advance,
> 
> ---
> Marcelo Carvalho Fernandes
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

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


[R-pkg-devel] Source code of an existing package

2016-08-10 Thread Marcelo Carvalho Fernandes
Hi all!

I am interested in seeing the source code of the boot.ci() function of the boot 
package.

Is it possible to have such source code? How?

Thanks in advance,

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


Re: [R-pkg-devel] Accessing R's linked PCRE library from inside a package

2016-08-10 Thread Dirk Eddelbuettel

On 10 August 2016 at 19:35, Oliver Keyes wrote:
| Neat; thanks Dirk! Will be interesting to see if I can get that finnagled on
| Windows when I get back to Boston.

Come to think about it, there is a bit of good fortune in my use as I

 - don't need to bother with include flags as pcre as a 'system library'
   so header are found
   
 - don't need to worry about version skew as there is only one pcre version
   on the system, and the header and library match

which will not generally be true in other, less developer-friendly environs.
But hey, that's your problem and not mine :)  

Dirk

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

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


Re: [R-pkg-devel] Accessing R's linked PCRE library from inside a package

2016-08-10 Thread Oliver Keyes
Neat; thanks Dirk! Will be interesting to see if I can get that finnagled
on Windows when I get back to Boston.

Best,
Oliver

On Wednesday, 10 August 2016, Dirk Eddelbuettel  wrote:

>
> On 10 August 2016 at 18:15, Oliver Keyes wrote:
> | I'm trying to incorporate PCRE-compliant regular expressions into C
> | code in an R package.
> |
> | >From digging around in R's source code, it appears that R (pretty
> | much?) guarantees the presence of either a system-level PCRE library,
> | or an R-internal one.[0] Is this exposed (or grabbable) via the R C
> | API in any way?
>
> The key to realize here is that R does indeed provide an environment.  And
> at
> least where I like to work, in get this right off the bat:
>
> edd@max:/tmp$ grep lpcre /etc/R/*
> /etc/R/Makeconf:LIBS =  -lpcre -llzma -lbz2 -lz -lrt -ldl -lm
> edd@max:/tmp$
>
> So pcre plus a bunch of compression libraries (lzma, bz2, z) and more are
> essentially "there for the taking". If built as a shared library.
>
> An existence proof is below; it is based on the 2nd Google hit I got for
> 'libpcre example' and has the advantge of being shorter than the first hit.
>
> I first created baseline. The example, as given and then repaired, gets us:
>
> edd@max:/tmp$ ./ex_pcre
>  0: From:regular.expressi...@example.com 
>  1: regular.expressions
>  2: example.com
>  0: From:ex...@43434.com 
>  1: exddd
>  2: 43434.com
>  0: From:7853...@exgem.com 
>  1: 7853456
>  2: exgem.com
> edd@max:/tmp$
>
> Turning that into something callable from R took about another minute. It
> looks like this:
>
> 
> -
> // modified (and repaired) example from http://stackoverflow.com/a/
> 1421923/143305
> #include "pcre.h"
> #include 
>
> // [[Rcpp::export()]]
> void foo() {
> const char *error;
> int   erroffset;
> pcre *re;
> int   rc;
> int   i;
> int   ovector[100];
>
> const char *regex = "From:([^@]+)@([^\r]+)";
> char str[]  = "From:regular.expressi...@example.com 
> \r\n"\
>   "From:ex...@43434.com \r\n"\
>   "From:7853...@exgem.com \r\n";
>
> re = pcre_compile (regex,  /* the pattern */
>PCRE_MULTILINE,
>, /* for error message */
>, /* for error offset */
>0); /* use default character tables */
> if (!re) Rcpp::stop("pcre_compile failed (offset: %d), %s\n",
> erroffset, error);
>
> unsigned int offset = 0;
> unsigned int len= strlen(str);
> while (offset < len && (rc = pcre_exec(re, 0, str, len, offset, 0,
> ovector, sizeof(ovector))) >= 0) {
> for(int i = 0; i < rc; ++i) {
> Rprintf("%2d: %.*s\n", i, ovector[2*i+1] - ovector[2*i], str +
> ovector[2*i]);
> }
> offset = ovector[1];
> }
> }
>
> /*** R
> foo()
> */
> 
> -
>
> and, lo and behold, produces the same output demonstrating that, yes,
> Veronica, we do get pcre for free:
>
> R> library(Rcpp)
> R> sourceCpp("/tmp/oliver.cpp")
>
> R> foo()
>  0: From:regular.expressi...@example.com 
>  1: regular.expressions
>  2: example.com
>  0: From:ex...@43434.com 
>  1: exddd
>  2: 43434.com
>  0: From:7853...@exgem.com 
>  1: 7853456
>  2: exgem.com
> R>
>
> Your package will probably want to a litmus test in configure to see if
> this
> really holds on the platform it is currently being built on.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
> 
>
>

[[alternative HTML version deleted]]

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


Re: [R-pkg-devel] Accessing R's linked PCRE library from inside a package

2016-08-10 Thread Dirk Eddelbuettel

On 10 August 2016 at 18:15, Oliver Keyes wrote:
| I'm trying to incorporate PCRE-compliant regular expressions into C
| code in an R package.
| 
| >From digging around in R's source code, it appears that R (pretty
| much?) guarantees the presence of either a system-level PCRE library,
| or an R-internal one.[0] Is this exposed (or grabbable) via the R C
| API in any way?

The key to realize here is that R does indeed provide an environment.  And at
least where I like to work, in get this right off the bat:

edd@max:/tmp$ grep lpcre /etc/R/*
/etc/R/Makeconf:LIBS =  -lpcre -llzma -lbz2 -lz -lrt -ldl -lm
edd@max:/tmp$ 

So pcre plus a bunch of compression libraries (lzma, bz2, z) and more are
essentially "there for the taking". If built as a shared library.

An existence proof is below; it is based on the 2nd Google hit I got for
'libpcre example' and has the advantge of being shorter than the first hit.

I first created baseline. The example, as given and then repaired, gets us:

edd@max:/tmp$ ./ex_pcre 
 0: From:regular.expressi...@example.com
 1: regular.expressions
 2: example.com
 0: From:ex...@43434.com
 1: exddd
 2: 43434.com
 0: From:7853...@exgem.com
 1: 7853456
 2: exgem.com
edd@max:/tmp$ 

Turning that into something callable from R took about another minute. It
looks like this:

-
// modified (and repaired) example from 
http://stackoverflow.com/a/1421923/143305
#include "pcre.h"
#include 

// [[Rcpp::export()]]
void foo() {
const char *error;
int   erroffset;
pcre *re;
int   rc;
int   i;
int   ovector[100];

const char *regex = "From:([^@]+)@([^\r]+)";
char str[]  = "From:regular.expressi...@example.com\r\n"\
  "From:ex...@43434.com\r\n"\
  "From:7853...@exgem.com\r\n";

re = pcre_compile (regex,  /* the pattern */
   PCRE_MULTILINE,
   , /* for error message */
   , /* for error offset */
   0); /* use default character tables */
if (!re) Rcpp::stop("pcre_compile failed (offset: %d), %s\n", erroffset, 
error);

unsigned int offset = 0;
unsigned int len= strlen(str);
while (offset < len && (rc = pcre_exec(re, 0, str, len, offset, 0, ovector, 
sizeof(ovector))) >= 0) {
for(int i = 0; i < rc; ++i) {
Rprintf("%2d: %.*s\n", i, ovector[2*i+1] - ovector[2*i], str + 
ovector[2*i]);
}
offset = ovector[1];
}
}

/*** R
foo()
*/
-

and, lo and behold, produces the same output demonstrating that, yes,
Veronica, we do get pcre for free:

R> library(Rcpp)
R> sourceCpp("/tmp/oliver.cpp")

R> foo()
 0: From:regular.expressi...@example.com
 1: regular.expressions
 2: example.com
 0: From:ex...@43434.com
 1: exddd
 2: 43434.com
 0: From:7853...@exgem.com
 1: 7853456
 2: exgem.com
R> 

Your package will probably want to a litmus test in configure to see if this
really holds on the platform it is currently being built on.

Dirk

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

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


[R-pkg-devel] Accessing R's linked PCRE library from inside a package

2016-08-10 Thread Oliver Keyes
Hey all,

I'm trying to incorporate PCRE-compliant regular expressions into C
code in an R package.

>From digging around in R's source code, it appears that R (pretty
much?) guarantees the presence of either a system-level PCRE library,
or an R-internal one.[0] Is this exposed (or grabbable) via the R C
API in any way?

Thanks!

Best,
Oliver

https://github.com/wch/r-source/blob/e5b21d0397c607883ff25cca379687b86933d730/src/main/grep.c#L75-L79

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


[R-pkg-devel] Looking for info on how CRAN package developers handle breaking changes with other packages

2016-08-10 Thread Chris Bogart
Hi, I'm looking for some help from developers who write R packages. My
research group is interested in the choices package managers and
repositories are make when designing their ecosystems. Newer packaging
and modules systems like Node.js/NPM, Google's go language, Python's
PyPI, are making very different design choices from each other, and
they are very different (and probably informed by) older packaging
systems like R's CRAN and Perl's CPAN. We'd like to know what the
impact of those design choices are on how you negotiate breaking
changes among R package developers when the packages depend on each
other. We're also interested in what values you think CRAN's design is
trying to optimize.

Could I ask people to take ~20 minutes of your time and fill out our
survey at http://breakingapis.org/survey? We'll report back to the R
community the results (or there's a sign up link to be notified when
results are out at http://breakingapis.org).

(If you distribute R packages in other ways, like Bioconductor or
devtools/Github; or if you use other ecosystems altogether such as
Node.js/NPM, Python/PyPI, Hackage, or something else, we're still
interested -- just make a different "software ecosystem" choice on the
first page. The study is a comparison among ecosystems; CRAN is one
point of comparison).

Thank you,
Chris Bogart
Institute for Software Research
Carnegie Mellon University
cbog...@cs.cmu.edu

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


[R-pkg-devel] Selective/Partial LazyData?

2016-08-10 Thread Alexandre Courtiol
Dear all,
I am preparing a package and using "LazyData: true" in DESCRIPTION makes
things a little more smooth as I have function calling my own data. My
problem is that doing so seem to uncompress the data at installation and
convert them into a Rdata.rdb that is > 1MB, which makes R CMD check, which
them threw a note. Adding "LazyDataCompression: xz" did help a bit, but I
am still far off the 1MB limit (9MB). Since I would rather keep both the
data and the LazyData, I wonder:
- if CRAN would only care about the size of the data within the tarball
(there, all is fine).
- if there is a way not to lazyload _all_ data objects, but only some of
them as I do not need the biggest file to be lazyloaded, just some small
ones.
Sorry if I failed to spot the relevant section in the R manuals... I did
look for it.
Alex

-- 
Alexandre Courtiol

http://sites.google.com/site/alexandrecourtiol/home

*"Science is the belief in the ignorance of experts"*, R. Feynman

[[alternative HTML version deleted]]

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


Re: [R-pkg-devel] Would CRAN accept a package that requires cmake?

2016-08-10 Thread Ege Rubak



On 08/10/2016 04:05 PM, Dirk Eddelbuettel wrote:


On 10 August 2016 at 08:39, Charles Determan wrote:
| I have seen this previous discussion (
| https://stat.ethz.ch/pipermail/r-package-devel/2015q2/000115.html) on this
| question but I didn't find a clear answer.  I am looking at integrating
| some more existing open-source C++ libraries to R packages.  However, a
| handful use/require cmake for compilation.  I believe this is possible to
| do using the configure(.win) files but I want to make sure this would be
| acceptable to CRAN.


  Only CRAN can answer CRAN questions.


With the above caveat, I'd say yes -- but do mark it clearly in
SystemRequirements: which is the field for this very purpose.

Dirk



Judging from this email from Uwe Ligges, CRAN is indeed open to using 
cmake to compile a package:

https://stat.ethz.ch/pipermail/r-package-devel/2016q2/000903.html
Appears you have to ask him to install the relevant version though.
Good luck!
Ege

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