[Rd] winbuilder warning message wrt function pointers

2017-12-29 Thread Therneau, Terry M., Ph.D.
I've recently updated the coxme package, which calls internal routines from the bdsmatrix 
package.  (It is in fact mentioned as an example of this in the Extensions manual.)

The call connections are a blocks like this, one for each of the 9 called C 
routines.

void bdsmatrix_prod4(int nrow,    int nblock,   int *bsize,
    double *bmat, double *rmat,
    int nfrail,   double *y) {
    static void (*fun)() = NULL;
    if (fun==NULL)
    fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
    fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
    }

..

The winbuilder run is flagging all of these with

bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between function pointer and 
'void *' [-Wpedantic]

  fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");

Ignore?  Or should these lines have been written in a different way?

Terry T.

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

[Rd] data compression in a package

2017-12-29 Thread Therneau, Terry M., Ph.D.

The submission guide has the following cryptic (to me) sentence:
   "Reasonable compression should be used for data (not just .rda files) "

The survival pacakge has a fairly large number of data files --- exactly what should I be 
doing?   xz compression?


Terry T.

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

Re: [Rd] data compression in a package

2017-12-29 Thread Dirk Eddelbuettel

On 29 December 2017 at 07:23, Therneau, Terry M., Ph.D. wrote:
| The submission guide has the following cryptic (to me) sentence:
|     "Reasonable compression should be used for data (not just .rda files) "
| 
| The survival pacakge has a fairly large number of data files --- exactly what 
should I be 
| doing?   xz compression?

See help(save) and its ilk -- compression is on by default. So just sit back
and revel in how yet another task is already taken care of by R.

Dirk

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

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


Re: [Rd] Numerical stability in chisq.test

2017-12-29 Thread Jan Motl
Hi,

there is also PR#8224, which seems to be relevant. I executed the following 
code:

## Modify the function
chisq.test2 <- edit(chisq.test) # Modify to use increasing order of sorting at 
line 57


## PR#8224 (patological contingency table)
m <- matrix(c(1,0,7,16),2,2);

# Original
original <- chisq.test(m, sim=T)$p.value
for(i in (1:2000)){original <- c(original, chisq.test(m, sim=T)$p.value)}

# Modified
modified <- chisq.test2(m, sim=T)$p.value
for(i in (1:2000)){modified <- c(modified, chisq.test2(m, sim=T)$p.value)}

# Evaluation
t.test(original, modified)


## PR#3486 (invariance to transposition)
x <- rbind(c(149, 151), c(1, 8))

# Original
c2x <- chisq.test(x, sim=T, B=10)$p.value
for(i in (1:200)){c2x<-c(c2x,chisq.test(x, sim=T,B=10)$p.value)}
c2tx <- chisq.test(t(x), sim=T, B=10)$p.value
for(i in (1:200)){c2tx<-c(c2tx,chisq.test(t(x), sim=T, B=10)$p.value)}
sum(abs(c2x-c2tx))

# Modified
mc2x <- chisq.test2(x, sim=T, B=10)$p.value
for(i in (1:200)){mc2x <- c(mc2x, chisq.test2(x, sim=T, B=10)$p.value)}
mc2tx <- chisq.test2(t(x), sim=T, B=10)$p.value
for(i in (1:200)){mc2tx <- c(mc2tx, chisq.test2(t(x), sim=T, B=10)$p.value)}
sum(abs(mc2x-mc2tx)) 

# Evaluation
t.test((c2x-c2tx), (mc2x-mc2tx))

on two computers:
1) OS: OS X 10.11.6, x86_64, darwin15.6.0; Version: R version 3.4.2 
(2017-09-28)
2) OS: Windows XP, i386, mingw32; Version: R version 3.4.3 (2017-11-30)

On both computers, the increasing and decreasing order return approximately the 
same results. 

Best regards,
 Jan Motl

> My thoughts too. PR 3486 is about simulated tables that theoretically have 
> STATISTIC equal to the one observed, but come out slightly different, messing 
> up the simulated p value. The sort is not actually intended to squeeze the 
> very last bit of accuracy out of the computation, just to make sure that the 
> round-off affects equivalent tables in the same way. "Fixing" the code may 
> therefore unfix PR#3486; at the very least some care is required if this is 
> modified.  


[[alternative HTML version deleted]]

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


Re: [Rd] data compression in a package

2017-12-29 Thread Therneau, Terry M., Ph.D.



On 12/29/2017 07:34 AM, Dirk Eddelbuettel wrote:


On 29 December 2017 at 07:23, Therneau, Terry M., Ph.D. wrote:
| The submission guide has the following cryptic (to me) sentence:
|     "Reasonable compression should be used for data (not just .rda files) "
|
| The survival pacakge has a fairly large number of data files --- exactly what 
should I be
| doing?   xz compression?

See help(save) and its ilk -- compression is on by default. So just sit back
and revel in how yet another task is already taken care of by R.

Dirk



Ah -just a grammar issue.  I was reading it as "do good compression for your rda files and 
everthing else too", and your interpretation is "remember the other data (not just rda 
which is already taken care of)."  The survival package has about 2M of .rda files and 
2.2M of vignettes so I'm still under the 5M boundary, but R CMD check nags about it.


Terry T.

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

Re: [Rd] data compression in a package

2017-12-29 Thread Dirk Eddelbuettel

On 29 December 2017 at 07:59, Therneau, Terry M., Ph.D. wrote:
| which is already taken care of)."  The survival package has about 2M of .rda 
files and 
| 2.2M of vignettes so I'm still under the 5M boundary, but R CMD check nags 
about it.

The nags are genuinely irritating, especially as they are neither "inflation
adjusted" nor user-adjustable or suppressable (and I mentioned frequently how
Debian package checks allow us maintainers to control the latter part).

If I had penny for each warning I got for Rcpp, BH, ... being "large" I could
go off and (almost) buy a bitcoin.

Dirk

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

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


Re: [Rd] Typos in ?regex

2017-12-29 Thread Uwe Ligges

Thanks, fixed in R-devel and R-patched.

Best,
Uwe Ligges


On 22.12.2017 15:28, Korpela Mikko (MML) wrote:

I found three little typos in the ?regex manual. Apologies for the lack of a 
diff, as the utility is not (yet) installed on this machine.

1. "There is a also" should probably be "There is also".
2. In the list of functions following "This section covers the regular expressions"..., 
"grep" appears twice. The other one should probably be "grepl".
3. In the "See Also" entry for TRE documentation, there is a spurious closing 
parenthesis.

- Mikko



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


Re: [Rd] winbuilder warning message wrt function pointers

2017-12-29 Thread William Dunlap via R-devel
Try changing
  static void (*fun)() = NULL;
to
  DL_FUNC fun = NULL;

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Dec 29, 2017 at 5:14 AM, Therneau, Terry M., Ph.D. <
thern...@mayo.edu> wrote:

> I've recently updated the coxme package, which calls internal routines
> from the bdsmatrix package.  (It is in fact mentioned as an example of this
> in the Extensions manual.)
> The call connections are a blocks like this, one for each of the 9 called
> C routines.
>
> void bdsmatrix_prod4(int nrow,int nblock,   int *bsize,
> double *bmat, double *rmat,
> int nfrail,   double *y) {
> static void (*fun)() = NULL;
> if (fun==NULL)
> fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
> fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
> }
>
> ..
>
> The winbuilder run is flagging all of these with
>
> bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between function
> pointer and 'void *' [-Wpedantic]
>   fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>
> Ignore?  Or should these lines have been written in a different way?
>
> Terry T.
>
> __
> 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


Re: [Rd] winbuilder warning message wrt function pointers

2017-12-29 Thread William Dunlap via R-devel
And remove the cast on the return value of R_GETCCallable.  And check
that your function is found before using it.

#include 
#include 
#include 

void bdsmatrix_prod4(int nrow,int nblock,   int *bsize,
double *bmat, double *rmat,
int nfrail,   double *y) {
DL_FUNC fun = NULL;
if (fun==NULL) {
fun = R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
}
if (fun==NULL) {
Rf_error("Cannot find C function 'bdsmatrix_prod4' in library
'bdsmatrix.{so,dll}'");
}
fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
}




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Dec 29, 2017 at 8:48 AM, William Dunlap  wrote:

> Try changing
>   static void (*fun)() = NULL;
> to
>   DL_FUNC fun = NULL;
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Fri, Dec 29, 2017 at 5:14 AM, Therneau, Terry M., Ph.D. <
> thern...@mayo.edu> wrote:
>
>> I've recently updated the coxme package, which calls internal routines
>> from the bdsmatrix package.  (It is in fact mentioned as an example of this
>> in the Extensions manual.)
>> The call connections are a blocks like this, one for each of the 9 called
>> C routines.
>>
>> void bdsmatrix_prod4(int nrow,int nblock,   int *bsize,
>> double *bmat, double *rmat,
>> int nfrail,   double *y) {
>> static void (*fun)() = NULL;
>> if (fun==NULL)
>> fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>> fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
>> }
>>
>> ..
>>
>> The winbuilder run is flagging all of these with
>>
>> bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between function
>> pointer and 'void *' [-Wpedantic]
>>   fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>>
>> Ignore?  Or should these lines have been written in a different way?
>>
>> Terry T.
>>
>> __
>> 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


Re: [Rd] winbuilder warning message wrt function pointers

2017-12-29 Thread Therneau, Terry M., Ph.D.
Bill,
   That's a very nice solution.  It is both cleaner looking and preferable to 
track R's .h 
files.
However, some of my routines don't have void * as the return type (two are int 
*), and 
Rdynload has

    typedef void * (*DL_FUNC)();

Will this untruth mess anything up?

Terry T.

On 12/29/2017 10:52 AM, William Dunlap wrote:
> And remove the cast on the return value of R_GETCCallable.  And check
> that your function is found before using it.
>
> #include 
> #include 
> #include 
>
> void bdsmatrix_prod4(int nrow,    int nblock,   int *bsize,
>                     double *bmat, double *rmat,
>                     int nfrail,   double *y) {
>     DL_FUNC fun = NULL;
>     if (fun==NULL) {
>         fun = R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>     }
>     if (fun==NULL) {
>         Rf_error("Cannot find C function 'bdsmatrix_prod4' in library 
> 'bdsmatrix.{so,dll}'");
>     }
>     fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
>     }
>
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com 
>
> On Fri, Dec 29, 2017 at 8:48 AM, William Dunlap  > wrote:
>
> Try changing
>   static void (*fun)() = NULL;
> to
>   DL_FUNC fun = NULL;
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com 
>
> On Fri, Dec 29, 2017 at 5:14 AM, Therneau, Terry M., Ph.D. 
>  > wrote:
>
> I've recently updated the coxme package, which calls internal 
> routines from the
> bdsmatrix package.  (It is in fact mentioned as an example of this in 
> the
> Extensions manual.)
> The call connections are a blocks like this, one for each of the 9 
> called C
> routines.
>
> void bdsmatrix_prod4(int nrow,    int nblock, int *bsize,
>     double *bmat, double *rmat,
>     int nfrail,   double *y) {
>     static void (*fun)() = NULL;
>     if (fun==NULL)
>     fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>     fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
>     }
>
> ..
>
> The winbuilder run is flagging all of these with
>
> bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between 
> function
> pointer and 'void *' [-Wpedantic]
>   fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>
> Ignore?  Or should these lines have been written in a different way?
>
> Terry T.
>
> __
> 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

Re: [Rd] winbuilder warning message wrt function pointers

2017-12-29 Thread William Dunlap via R-devel
You can legally cast a function pointer to another function pointer, where
the signatures differ.  (It is not legal to cast between data and function
pointers.)
I would make typedefs for the various signatures, as the casting syntax is
more
readable then.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Dec 29, 2017 at 10:13 AM, Therneau, Terry M., Ph.D. <
thern...@mayo.edu> wrote:

> Bill,
>   That's a very nice solution.  It is both cleaner looking and preferable
> to track R's .h files.
> However, some of my routines don't have void * as the return type (two are
> int *), and Rdynload has
>
>typedef void * (*DL_FUNC)();
>
> Will this untruth mess anything up?
>
> Terry T.
>
> On 12/29/2017 10:52 AM, William Dunlap wrote:
>
> And remove the cast on the return value of R_GETCCallable.  And check
> that your function is found before using it.
>
> #include 
> #include 
> #include 
>
> void bdsmatrix_prod4(int nrow,int nblock,   int *bsize,
> double *bmat, double *rmat,
> int nfrail,   double *y) {
> DL_FUNC fun = NULL;
> if (fun==NULL) {
> fun = R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
> }
> if (fun==NULL) {
> Rf_error("Cannot find C function 'bdsmatrix_prod4' in library
> 'bdsmatrix.{so,dll}'");
> }
> fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
> }
>
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Fri, Dec 29, 2017 at 8:48 AM, William Dunlap  wrote:
>
>> Try changing
>>   static void (*fun)() = NULL;
>> to
>>   DL_FUNC fun = NULL;
>>
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>>
>> On Fri, Dec 29, 2017 at 5:14 AM, Therneau, Terry M., Ph.D. <
>> thern...@mayo.edu> wrote:
>>
>>> I've recently updated the coxme package, which calls internal routines
>>> from the bdsmatrix package.  (It is in fact mentioned as an example of this
>>> in the Extensions manual.)
>>> The call connections are a blocks like this, one for each of the 9
>>> called C routines.
>>>
>>> void bdsmatrix_prod4(int nrow,int nblock,   int *bsize,
>>> double *bmat, double *rmat,
>>> int nfrail,   double *y) {
>>> static void (*fun)() = NULL;
>>> if (fun==NULL)
>>> fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>>> fun(nrow, nblock, bsize, bmat, rmat, nfrail, y);
>>> }
>>>
>>> ..
>>>
>>> The winbuilder run is flagging all of these with
>>>
>>> bdsmatrix_stub.h:22:6: warning: ISO C forbids assignment between
>>> function pointer and 'void *' [-Wpedantic]
>>>   fun = (void (*)) R_GetCCallable("bdsmatrix", "bdsmatrix_prod4");
>>>
>>> Ignore?  Or should these lines have been written in a different way?
>>>
>>> Terry T.
>>>
>>> __
>>> 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