Re: [Rd] as.POSIXct behaviour

2017-03-08 Thread Suzen, Mehmet
On 9 March 2017 at 01:29, Arunkumar Srinivasan
 wrote:
> The time info is lost on the first index as well. And it happens *silently*.

Yes, because it assumes homogeneous format on the entire vector.  You
may want to
do  two passes with different formats or run a regular expression to
catch typos.

> lapply(x, as.POSIXct)
> A list is returned, but values are as I’d expect. Would it be possible
> to retain the time info with as.POSIXct(x) directly as well? If not,

This behaves differently because you are running as.POSIXct for each element
separately.

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

Re: [Rd] Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3)

2017-03-08 Thread Spencer Graves

Hello:


  I tried "debug(help)" with the problem mentioned below.  It 
stopped with a call to "library", from which I generate the following 
simple replication of this error:



> library(help = 'fda', character.only = TRUE)
Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
  incorrect values of 'indent' and 'width'


  This was using R 3.3.3 inside RStudio on a Mac, as noted below.  
This same "library(help='fda', character.only=TRUE)" ran fine using R 
Console 3.2.1 under Windows 7.



  I also tried debug(library).  It died in line 298:


for (i in which(file.exists(docFiles))) pkgInfo[[i]] <- 
readDocFile(docFiles[i])



  with i = 1 and docFiles[i] = 
"/Library/Frameworks/R.framework/Versions/3.3/Resources/library/fda/Meta/package.rds". 




  This looks like a bug to me.  I don't know if it's new since R 
3.2.1 or it works fine under Windows 7 but not a Mac.



  Thanks,
  Spencer Graves


*** NOTES:


  1.  When I tried "Q" to exit debug mode, I got, "Error retrieving 
help:  R code execution error."  This suggests a bug in "debug", which 
could be replicated by trying debug(help) with "help(package='fda', 
help_type='text')".  It does not want to exit from "help" using "Q".  
"c" also fails.



  2.  For sessionInfo(), see below.


On 2017-03-08 4:06 PM, Spencer Graves wrote:

Hello:


  A call to help(..., help_type='text') fails with "package='fda":


> install.packages('fda')
> help(package='fda', help_type='text')
Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
  incorrect values of 'indent' and 'width'


  I have this wrapped inside "try" in PackageSum2{sos}, so it 
doesn't die, but it also doesn't give me the additional information I 
want from help(..., help_type='text')



  Is this a bug?
  Thanks,
  Spencer Graves

Using RStudio 1.0.136 with


> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets
[6] methods   base

loaded via a namespace (and not attached):
[1] tools_3.3.3

__
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: [Bioc-devel] badges for Bioconductor package

2017-03-08 Thread Leonardo Collado Torres
This is cool! Thanks Guangchuang!

On Wed, Mar 8, 2017 at 10:18 PM, Yu, Guangchuang  wrote:
>
> Dear all,
>
> I have some simple functions to create badges for using in README or github
> pages.
>
> See ggtree project website  and
> README  as
> examples.
> I think someone may also interesting in using these badges to present
> related information, including download stats, version, *etc*.
>
> I have packed these functions to a simple package, badger, which is now
> available on CRAN. You can find examples in my github repo
> .
> Bests,
> Guangchuang
> --
> --~--~-~--~~~---~--~~
> Guangchuang Yu, PhD Candidate
> State Key Laboratory of Emerging Infectious Diseases
> School of Public Health
> The University of Hong Kong
> Hong Kong SAR, China
> www: https://guangchuangyu.github.io
> -~--~~~~--~~--~--~---
>
> [[alternative HTML version deleted]]
>
> ___
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel


[Bioc-devel] badges for Bioconductor package

2017-03-08 Thread Yu, Guangchuang
Dear all,

I have some simple functions to create badges for using in README or github
pages.

See ggtree project website  and
README  as
examples.
I think someone may also interesting in using these badges to present
related information, including download stats, version, *etc*.

I have packed these functions to a simple package, badger, which is now
available on CRAN. You can find examples in my github repo
.
Bests,
Guangchuang
-- 
--~--~-~--~~~---~--~~
Guangchuang Yu, PhD Candidate
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong
Hong Kong SAR, China
www: https://guangchuangyu.github.io
-~--~~~~--~~--~--~---

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel


[Rd] as.POSIXct behaviour

2017-03-08 Thread Arunkumar Srinivasan
Dear R-devel, I have tested the code below on R v3.3.2 and v3.3.3 on
Mac and Windows.

x <- c("2017-01-01 05:00:02", "2017-01-02 03 :M:00") # note the ‘ :M’
in 2nd value
as.POSIXct(x)
# [1] "2017-01-01 GMT" "2017-01-02 GMT”

The time info is lost on the first index as well. And it happens *silently*.

On the other hand, if I do:

lapply(x, as.POSIXct)
# [[1]]
# [1] "2017-01-01 05:00:02 GMT"
#
# [[2]]
# [1] "2017-01-02 GMT”

A list is returned, but values are as I’d expect. Would it be possible
to retain the time info with as.POSIXct(x) directly as well? If not,
what’s the rationale? In addition, I think a warning message that some
malformed timestamps were found would be very useful.

Thank you,
Arun.

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

[Rd] Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3)

2017-03-08 Thread Spencer Graves

Hello:


  A call to help(..., help_type='text') fails with "package='fda":


> install.packages('fda')
> help(package='fda', help_type='text')
Error in formatDL(nm, txt, indent = max(nchar(nm, "w")) + 3) :
  incorrect values of 'indent' and 'width'


  I have this wrapped inside "try" in PackageSum2{sos}, so it 
doesn't die, but it also doesn't give me the additional information I 
want from help(..., help_type='text')



  Is this a bug?
  Thanks,
  Spencer Graves

Using RStudio 1.0.136 with


> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets
[6] methods   base

loaded via a namespace (and not attached):
[1] tools_3.3.3

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


Re: [Bioc-devel] Writing examples for accessing web API

2017-03-08 Thread Welliton Souza
Martin,

I am using the "Template for Resource Queries" (
http://bioconductor.org/developers/how-to/web-query/). I think the correct
is:

while (N.TRIES > 0L) { # line 5

instead of

while (N.TRIES >= 0L) { # line 5

Because it will run twice when N.TRIES = 1L. At the end of the loop N.TRIES
should be 0 not -1. Or this line will fail.

if (N.TRIES == 0L) { # line 12

Welliton

On Tue, Mar 7, 2017 at 5:15 PM Welliton Souza  wrote:

> Thank you Martin for the response, it was very helpful.
>
> I am facing difficulties to write code examples, unit tests and vignettes
> for accessing web APIs. I understand that the use of \dontrun{} is not the
> best solution for examples. I am using testthat::skip_on_bioc() to avoid
> time consuming and internet connection during execution of unit tests. I
> also using pre-cached response data (Rda file) for vignettes because I
> didn't find a cache solution for knitr/Rmarkdown. It would be very useful a
> package that helps us caching web response data and time consuming results
> that can be used in examples, unit tests and vignettes.
>
> Welliton
>
>
> On Tue, Mar 7, 2017 at 4:49 PM Martin Morgan <
> martin.mor...@roswellpark.org> wrote:
>
> On 03/07/2017 02:35 PM, Welliton Souza wrote:
> > Thank you Nan Xiao, I think it is a good solution for my case. I will put
> > the definition of host outside the \dontrun{}.
>
> Actually, generally, one doesn't want to work around tests with hacks,
> but either (a) address the underlying problem or (b) justify what the
> current behavior is and live with the warning. Writing  \dontrun{}
> doesn't help  at all -- it might work now, but will suffer from 'bit
> rot' in the future; example and vignette code is littered with examples
> like this.
>
> The usual problem with web resources is that the functions that access
> them assume that the resource is reliably available, and that band width
> is infinite. In reality, the web resource is likely to experience
> periodic down time, and the band width can be cripplingly slow.
>
> There are a few notes here
>
>http://bioconductor.org/developers/how-to/web-query/
>
> discussing better practice for querying web resources. Avoiding
> infinitely querying a web resource and including a time out are two
> important steps.
>
> Ideally one would like unit tests that verify that the web resource is
> in fact alive, and that the expected API is available. One would not
> necessarily test the entire API, but rely instead on serialized
> instances to ensure that one parses the correct information.
>
> With examples, there is a combination of judicious use of web calls
> coupled with re-use of data from previous calls. The forthcoming
> BiocFileCache (https://github.com/Bioconductor/BiocFileCache) might be
> used to create a temporary cache used during the duration of the build /
> check, limiting the number of unique calls required while still exposing
> substantial functionality in the example pages.
>
> Martin
>
> >
> > Welliton
> >
> > Em ter, 7 de mar de 2017 16:27, Nan Xiao  escreveu:
> >
> >> - this check can be bypassed by
> >> writing "partially working" examples,
> >> for instance:
> >>
> >> #' token = "foo"
> >> #' \dontrun{
> >> #' api(..., token)}
> >>
> >> Best,
> >> -Nan
> >>
> >> On Tue, Mar 7, 2017 at 2:13 PM, Welliton Souza 
> wrote:
> >>
> >> Hi Sean,
> >>
> >> It doesn't require authentication. I've been using this server (
> >> http://1kgenomes.ga4gh.org) to provide working examples and do unit
> tests
> >> but I am not responsible for this server. However the package was
> developed
> >> to access any server endpoint that use the same API. There are many web
> >> resources to cover, the package takes some time to run all examples.
> >>
> >> Welliton
> >>
> >>
> >> Em ter, 7 de mar de 2017 16:03, Sean Davis 
> escreveu:
> >>
> >> Hi, Welliton.
> >>
> >> Great question.  Just out of curiosity, what are the internet connection
> >> requirements that preclude running examples?  Is authentication
> required?
> >> Or are you connecting to a server that runs only intermittently?
> >>
> >> Sean
> >>
> >>
> >> On Tue, Mar 7, 2017 at 1:57 PM, Welliton Souza 
> wrote:
> >>
> >> Hi,
> >>
> >> I am developing a package that access web API endpoints. I wrote the
> >> examples within \dontrun{} due to internet connection requirements.
> >> However, the BiocCheck reports that I should provide at least 80 % of
> >> running examples. What I should do? The package is mainly focused on
> >> accessing web API and processing response data.
> >>
> >> Best regards,
> >> Welliton Souza
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ___
> >> Bioc-devel@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/bioc-devel
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> ___
> 

Re: [Rd] Bug in nlm()

2017-03-08 Thread Martin Maechler
   {This was sent to me, MM, only, but for completeness should
have gone back to R-devel.

Further: I now *have* added Marie B to the members'of "R bugzilla"
-- M.Maechler}


I had already read the R bug reporting guide and I'm sure it is a bug.
The bug occurs when the user provides not only the analytic gradient but also 
the analytic Hessian of the objective function. In that case, the algorithm 
does not converge due to an erroneous implementation of the modified Cholesky 
decomposition of the Hessian matrix. It is actually a bug in the C-code called 
by nlm(), therefore it is hard to show that the non-convergence of the 
algorithm is really due to this bug with only a MRE.
However, a short example (optimizing the Rosenbrock banana valley function with 
and without analytic Hessian) is:

fg <- function(x){  
  gr <- function(x1, x2) c(-400*x1*(x2 - x1*x1)-2*(1-x1), 200*(x2 - x1*x1)) 
  x1 <- x[1]; x2 <- x[2]
  res<- 100*(x2 - x1*x1)^2 + (1-x1)^2 
  attr(res, "gradient") <- gr(x1, x2)
  return(res)
} 
nlm.fg <- nlm(fg, c(-1.2, 1))

fgh <- function(x){ 
  gr <- function(x1, x2) c(-400*x1*(x2 - x1*x1) - 2*(1-x1), 200*(x2 - x1*x1)) 
  h <- function(x1, x2){
a11 <- 2 - 400*x2 + 1200*x1*x1
a21 <- -400*x1 
matrix(c(a11, a21, a21, 200), 2, 2)
  } 
  x1 <- x[1];  x2 <- x[2];  res<- 100*(x2 - x1*x1)^2 + (1-x1)^2 
  attr(res, "gradient") <- gr(x1, x2)
  attr(res, "hessian") <- h(x1, x2) 
  return(res)
}
nlm.fgh <- nlm(fgh, c(-1.2,1))

I have almost finished a more detailed bug report, which I would like to submit.

Best,
Marie Boehnstedt

> Martin Maechler 
> on Fri, 3 Mar 2017 18:15:47 +0100 writes:

> Boehnstedt, Marie 
> on Fri, 3 Mar 2017 10:23:12 + writes:

>> Dear all, I have found a bug in nlm() and would like to
>> submit a report on this.  Since nlm() is in the
>> stats-package, which is maintained by the R Core team,
>> bug reports should be submitted to R's Bugzilla. However,
>> I'm not a member of Bugzilla. Could anyone be so kind to
>> add me to R's Bugzilla members or let me know to whom I
>> should send the bug report?

> Dear Marie,

> I can do this ... but are you really sure?  There is
> https://www.r-project.org/bugs.html which you should spend
> some time reading if you haven't already.

> I think you would post a MRE (Minimal Reproducible
> Example) here {or on stackoverflow or ...} if you'd follow
> what the 'R bugs' web page (above) recommends and only
> report a bug after some feedback from "the public".

> Of course, I could be wrong.. and happy if you explain /
> tell me why.

> Best, Martin Maechler

>> Thank you in advance.

>> Kind regards, Marie B�hnstedt


>> Marie B�hnstedt, MSc Research Scientist Max Planck
>> Institute for Demographic Research Konrad-Zuse-Str. 1,
>> 18057 Rostock, Germany
>> www.demogr.mpg.de

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