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
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 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: [R-pkg-devel] File name error

2017-12-29 Thread Uwe Ligges



On 21.12.2017 18:22, Henrik Bengtsson wrote:
Uwe/Kurt, is this 


You mean the new check? This is R.


controlled by R itself or by the host system?  I
suspect one of my R.filesets tests(*) fails (since a few days) because
of this, but it might actually be a false positive.  I fail to
reproduce it on Ubuntu 16.04 with:

* using R Under development (unstable) (2017-12-20 r73933)
* using platform: x86_64-pc-linux-gnu (64-bit)

My test tries to verify that it can write to tempdir() using its
*relative* path (if such is possible) - a test that effectively does:


abs <- tempfile()
setwd(dirname(abs))
getwd()

[1] "/tmp/Rtmpa9riPQ"

rel <- file.path("..", "..", abs)
rel <- gsub("//", "/", rel, fixed = TRUE)
rel

[1] "../../tmp/Rtmpa9riPQ/file3251441e380d

cat("hello", file = res)


file = rel, I guess.




and fails in that last write on 'r-devel-linux-x86_64-debian-gcc'.  It
could, of course, be a bug in my code that is now being revealed, but
these tests been in place for many years, possibly more than a decade.

(*) https://cran.r-project.org/web/checks/check_results_R.filesets.html



Well, as this is also shown in R-release on Kurt's machines, I suspect 
this is either a problem where the directory you are working in is a 
link and the deriving the relative path fails or there is no space left 
in  tempdir() ...


In both cases, please ask Kurt who is on vacation, too.

Best,
Uwe







Thxs,

Henrik

On Thu, Dec 21, 2017 at 2:21 AM, Uwe Ligges
 wrote:

This is a new check:

You must not write into the user's filespace without explicit agreement by
the user (by specifying path/name).

Note that some users won't even have permissions to write into the package's
installation directory if that is set up site wide by an admin, for example.

So please use tempdir() in the examples.

Best,
Uwe Ligges





On 21.12.2017 09:21, Blume Christine wrote:


Hi Cathy,

I also had troubles with debian (Fedora only gave warnings) and no
problems with other systems. Mine was related to me writing a file (or
rather trying to write) in a working directory other than tempdir (can be
retrieved by tempdir()). I now write it to tempdir and then set the old
working directory again at the end of the example. Perhaps that is somehow
helpful for your case too?

I can highly recommend to test your tar.gz file with the check() function
of the rhub package. You can for example run check("pathtoyourpackage",
platform = "debian-gcc-devel") or
check_for_cran("pathtoyourpackage", platform = "debian-gcc-devel"), i.e.
test your package on debian without troubles.

Best,
Christine


-Ursprüngliche Nachricht-
Von: R-package-devel [mailto:r-package-devel-boun...@r-project.org] Im
Auftrag von Cathy Lee Gierke
Gesendet: Donnerstag, 21. Dezember 2017 07:15
An: R Package Development
Betreff: [R-pkg-devel] File name error

I am getting the following error from the auto-checks when trying to
submit a package to CRAN:
r-devel-linux-x86_64-debian-gcc


3.0.0.2 3.63 56.71 60.34 ERROR



Error in pdf(file = fileName4, width = 8, height = 10) :
cannot open file

'/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/CATkit/extdata/activity-stress-c57-2-part.txt--20Dec2017--03-51-46CAToutput.pdf'

Since this works for ALL other flavors, I am assuming it may be some file
name restrictions unique to debian-gcc???  I can't think what else would
cause it to fail only in the OS.

debian doesn't like "--"?

Cathy Lee Gierke


*“Darkness cannot drive out darkness: only light can do that. Hate cannot
drive out hate: only love can do that.” * *“The arc of the moral universe is
long, but it bends towards justice.”* *“Nothing in the world is more
dangerous than sincere ignorance and conscientious stupidity.” *
*“Never forget that everything Hitler did in Germany was legal.”   *
*“Forgiveness is not an occasional act, it is a constant attitude.” *
*“Injustice anywhere is a threat to justice everywhere.”  *

― Martin Luther King Jr.



 [[alternative HTML version deleted]]

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

Re: [R-pkg-devel] File name error

2017-12-29 Thread Uwe Ligges



On 27.12.2017 18:55, Cathy Lee Gierke wrote:

My program puts the output into the folder where it found the input.


Please let the user specify the output dir. Otherwise there is the risk 
to overwrite files that the user want to keep.





Must I move the input files to tmpdir() or are they already there?


Why shoudl files be in tmpdir()? Only those you created there...

Best,
Uwe Ligges





Cathy Lee Gierke

/“Darkness cannot drive out darkness: only light can do that. Hate 
cannot drive out hate: only love can do that.”

/
/“The arc of the moral universe is long, but it bends towards justice.”/
/“Nothing in the world is more dangerous than sincere ignorance and 
conscientious stupidity.” /

/“Never forget that everything Hitler did in Germany was legal.” /
/“Forgiveness is not an occasional act, it is a constant attitude.” /
/“Injustice anywhere is a threat to justice everywhere.” /

― Martin Luther King Jr.



On Thu, Dec 21, 2017 at 4:21 AM, Uwe Ligges 
> wrote:


This is a new check:

You must not write into the user's filespace without explicit
agreement by the user (by specifying path/name).

Note that some users won't even have permissions to write into the
package's installation directory if that is set up site wide by an
admin, for example.

So please use tempdir() in the examples.

Best,
Uwe Ligges





On 21.12.2017 09:21, Blume Christine wrote:

Hi Cathy,

I also had troubles with debian (Fedora only gave warnings) and
no problems with other systems. Mine was related to me writing a
file (or rather trying to write) in a working directory other
than tempdir (can be retrieved by tempdir()). I now write it to
tempdir and then set the old working directory again at the end
of the example. Perhaps that is somehow helpful for your case too?

I can highly recommend to test your tar.gz file with the check()
function of the rhub package. You can for example run
check("pathtoyourpackage", platform = "debian-gcc-devel") or
check_for_cran("pathtoyourpackage", platform =
"debian-gcc-devel"), i.e. test your package on debian without
troubles.

Best,
Christine


-Ursprüngliche Nachricht-
Von: R-package-devel
[mailto:r-package-devel-boun...@r-project.org
] Im Auftrag von
Cathy Lee Gierke
Gesendet: Donnerstag, 21. Dezember 2017 07:15
An: R Package Development
Betreff: [R-pkg-devel] File name error

I am getting the following error from the auto-checks when
trying to submit a package to CRAN:
r-devel-linux-x86_64-debian-gcc

>
3.0.0.2 3.63 56.71 60.34 ERROR

>

Error in pdf(file = fileName4, width = 8, height = 10) :
    cannot open file

'/home/hornik/tmp/R.check/r-devel-gcc/Work/build/Packages/CATkit/extdata/activity-stress-c57-2-part.txt--20Dec2017--03-51-46CAToutput.pdf'

Since this works for ALL other flavors, I am assuming it may be
some file name restrictions unique to debian-gcc???  I can't
think what else would cause it to fail only in the OS.

debian doesn't like "--"?

Cathy Lee Gierke


*“Darkness cannot drive out darkness: only light can do that.
Hate cannot drive out hate: only love can do that.” * *“The arc
of the moral universe is long, but it bends towards justice.”*
*“Nothing in the world is more dangerous than sincere ignorance
and conscientious stupidity.” *
*“Never forget that everything Hitler did in Germany was legal.”   *
*“Forgiveness is not an occasional act, it is a constant
attitude.” * *“Injustice anywhere is a threat to justice
everywhere.”  *

― Martin Luther King Jr.

>

         [[alternative HTML version deleted]]

__
R-package-devel@r-project.org
 mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-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] 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] 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 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


[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

[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