[Rd] Suggested Patch: Library returns matching installed packages when typo present

2019-06-20 Thread Marcel Ramos
Dear R-core devs,

I hope this email finds you well.

Please see the proposed patch to R-devel below:

Scenario:

When loading a package using `library`, a package may not be found if the cases 
are not matching:

```
> library(ORG.Hs.eg.db)
 Error in library(ORG.Hs.eg.db) :
  there is no package called 'ORG.Hs.eg.db'
```


Suggested Patch:

Returns a message matching what `install.packages` returns in such situations:

```
> library("ORG.Hs.eg.db")
 Error in library("ORG.Hs.eg.db") :
   there is no package called 'ORG.Hs.eg.db'
 In addition: Warning message:
 Perhaps you meant 'org.Hs.eg.db' ?
```

This patch will be helpful with 'fat-finger' typos. It will match a package
called with `library` against installed packages.


svn diff:

Index: src/library/base/R/library.R
===
--- src/library/base/R/library.R(revision 76727)
+++ src/library/base/R/library.R(working copy)
@@ -300,8 +300,13 @@
 pkgpath <- find.package(package, lib.loc, quiet = TRUE,
 verbose = verbose)
 if(length(pkgpath) == 0L) {
-if(length(lib.loc) && !logical.return)
+if(length(lib.loc) && !logical.return) {
+allpkgs <- .packages(TRUE, lib.loc)
+if (!is.na(w <- match(tolower(package), tolower(allpkgs
+warning(sprintf("Perhaps you meant %s ?",
+sQuote(allpkgs[w])), call. = FALSE, domain = NA)
 stop(packageNotFoundError(package, lib.loc, sys.call()))
+}
 txt <- if(length(lib.loc))
 gettextf("there is no package called %s", sQuote(package))
 else


Thank you!

Best regards,

Marcel



--
Marcel Ramos
Bioconductor Core Team
Roswell Park Comprehensive Care Center
Dept. of Biostatistics & Bioinformatics
Elm & Carlton Streets
Buffalo, New York 14263


This email message may contain legally privileged and/or confidential 
information.  If you are not the intended recipient(s), or the employee or 
agent responsible for the delivery of this message to the intended 
recipient(s), you are hereby notified that any disclosure, copying, 
distribution, or use of this email message is prohibited.  If you have received 
this message in error, please notify the sender immediately by e-mail and 
delete this email message from your computer. Thank you.
[[alternative HTML version deleted]]

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


Re: [R-pkg-devel] access is denied

2019-06-20 Thread Jeff Newmiller
I have not had much luck doing package development on network drives. Try using 
a local drive.

On June 20, 2019 11:26:42 AM CDT, Tomas Kalibera  
wrote:
>If you have not already done so, I'd check the package directory (and 
>its parent) is not opened in any application, including Windows 
>Explorer, including current working directory in any command prompt.
>I'd 
>also make sure the package is not loaded in any R session. The error 
>message may be caused by that the file or directory is locked.
>
>Best
>Tomas
>
>On 6/20/19 5:49 PM, Dennis Boos wrote:
>> Developers,
>>
>> I recently was successful getting a package into CRAN with your help.
>> But now I'm working on a second package and am stuck immediately. 
>Here
>> is what I have done.
>>
>> 1. Created the base package using
>http://r-pkgs.had.co.nz/package.html
>> to get started.
>> 2. Then
>>
>>> library(devtools) > document() Updating fsr documentation First time
>> using roxygen2. Upgrading automatically... Error in
>> normalizePath(path.expand(path), winslash, mustWork) :
>>
>path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
>> Access is denied In addition: Warning messages: 1: In
>> normalizePath(path.expand(path), winslash, mustWork) :
>>
>path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
>> Access is denied 2: In normalizePath(path.expand(path), winslash,
>> mustWork) :
>>
>path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr/DESCRIPTION":
>> Access is denied
>>
>>
>> What am I missing?  I didn't have this problem before.  I have
>> re-downloaded RStudio and Rtools, but get the same results.
>>
>> Dennis
>>
>
>__
>R-package-devel@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R-pkg-devel] access is denied

2019-06-20 Thread Tomas Kalibera
If you have not already done so, I'd check the package directory (and 
its parent) is not opened in any application, including Windows 
Explorer, including current working directory in any command prompt. I'd 
also make sure the package is not loaded in any R session. The error 
message may be caused by that the file or directory is locked.


Best
Tomas

On 6/20/19 5:49 PM, Dennis Boos wrote:

Developers,

I recently was successful getting a package into CRAN with your help.
But now I'm working on a second package and am stuck immediately.  Here
is what I have done.

1. Created the base package using http://r-pkgs.had.co.nz/package.html
to get started.
2. Then


library(devtools) > document() Updating fsr documentation First time

using roxygen2. Upgrading automatically... Error in
normalizePath(path.expand(path), winslash, mustWork) :
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
Access is denied In addition: Warning messages: 1: In
normalizePath(path.expand(path), winslash, mustWork) :
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
Access is denied 2: In normalizePath(path.expand(path), winslash,
mustWork) :
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr/DESCRIPTION":
Access is denied


What am I missing?  I didn't have this problem before.  I have
re-downloaded RStudio and Rtools, but get the same results.

Dennis



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


[R-pkg-devel] access is denied

2019-06-20 Thread Dennis Boos
Developers,

I recently was successful getting a package into CRAN with your help.  
But now I'm working on a second package and am stuck immediately.  Here 
is what I have done.

1. Created the base package using http://r-pkgs.had.co.nz/package.html 
to get started.
2. Then

> library(devtools) > document() Updating fsr documentation First time 
using roxygen2. Upgrading automatically... Error in 
normalizePath(path.expand(path), winslash, mustWork) : 
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
 
Access is denied In addition: Warning messages: 1: In 
normalizePath(path.expand(path), winslash, mustWork) : 
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr":
 
Access is denied 2: In normalizePath(path.expand(path), winslash, 
mustWork) : 
path[1]="\\wolftech.ad.ncsu.edu\cos\stat\Redirect\boos\Documents\srcis\fsr.package\fsr/DESCRIPTION":
 
Access is denied


What am I missing?  I didn't have this problem before.  I have 
re-downloaded RStudio and Rtools, but get the same results.

Dennis

-- 
Dennis Boos, Assoc. Heademail: dennis_b...@ncsu.edu
Department of StatisticsPhone: 919-515-1918
NC State University Fax: 919-515-1169
Raleigh, NC 27695-8203  http://www4.stat.ncsu.edu/~boos

Aim for kindness, tolerance, and humility.
The rest of life will then fall into place.


[[alternative HTML version deleted]]

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


Re: [Rd] base::format adds extraneous whitespace for some inputs

2019-06-20 Thread Martin Maechler
> Sarah Goslee 
> on Thu, 20 Jun 2019 09:56:44 -0400 writes:

> I can reproduce this.
> It has to do with whether the value rounds down to 9 or up to 10, and
> thus needs another space, I think. I agree that it shouldn't happen,
> but at least you can get rid of the space by using trim = TRUE.

> # rounds to 9 vs 10

> format(9.95, digits = 2)
> format(9.96, digits = 2)

> format(9.95, digits = 2, nsmall = 2)
> format(9.96, digits = 2, nsmall = 2)

> format(9.95, digits = 2, nsmall = 2, trim=TRUE)
> format(9.96, digits = 2, nsmall = 2, trim=TRUE)

> # rounds to 99 vs 100

> format(99.94, digits = 3)
> format(99.95, digits = 3)

> format(99.94, digits = 3, nsmall = 2)
> format(99.95, digits = 3, nsmall = 2)

> format(99.94, digits = 3, nsmall = 2, trim=TRUE)
> format(99.95, digits = 3, nsmall = 2, trim=TRUE)

Yes, indeed;
I had wanted to reply earlier, but did not get to.

I agree that this is bogous;
I've never encountered it as I've (almost?) never used 'nsmall' consciously.

Interestingly, this behavior has probably existed unchanged for close to R's
full history.  The 'nsmall = *' optional argument (of
format.default() to be precise) was introduced in R 1.3.0   in 2001.

And in my still working version of R 1.3.1, behavior seems
similar (not identical) I think.

You can access the underlying computations using format.info()
from the R level. It calls into the C code which is really used here from the
.Internal(format(...))  C code :

e.g.

> format.info(9.91, 2, 2)
[1] 4 2 0

 ==> result will use 4 characters

> format.info(9.99, 2, 2)
[1] 5 2 0

 ==> result will use 5 characters



-

One more thing:  format() has really been designed (in S, and
inherited for R) to format *several* numbers, often matrices (or
data frames if you must) to be printed and look nicely.

For this (in cases like these, with numbers),
format() must find a common format for all numbers, and that is
the reason the underlying algorithm is quite sophisticated
because it needs to cover many border line cases, notably
deciding on when exponential format is needed, etc etc.


For format()ting simple numbers (i.e. numeric vectors of length *one*),
using  formatC()  (or even sprintf()  is typically faster and easier
to use--for sprintf() you need to know C-standard formatting a bit.


>> sessionInfo()
> R version 3.5.3 (2019-03-11)
> Platform: x86_64-redhat-linux-gnu (64-bit)
> Running under: Fedora 28 (Workstation Edition)

..

>> # rounds to 9 vs 10
>> 
>> format(9.95, digits = 2)
> [1] "9.9"
>> format(9.96, digits = 2)
> [1] "10"
>> 
>> format(9.95, digits = 2, nsmall = 2)
> [1] "9.95"
>> format(9.96, digits = 2, nsmall = 2)
> [1] " 9.96"
>> 
>> format(9.95, digits = 2, nsmall = 2, trim=TRUE)
> [1] "9.95"
>> format(9.96, digits = 2, nsmall = 2, trim=TRUE)
> [1] "9.96"
>> 
>> # rounds to 99 vs 100
>> 
>> format(99.94, digits = 3)
> [1] "99.9"
>> format(99.95, digits = 3)
> [1] "100"
>> 
>> format(99.94, digits = 3, nsmall = 2)
> [1] "99.94"
>> format(99.95, digits = 3, nsmall = 2)
> [1] " 99.95"
>> 
>> format(99.94, digits = 3, nsmall = 2, trim=TRUE)
> [1] "99.94"
>> format(99.95, digits = 3, nsmall = 2, trim=TRUE)
> [1] "99.95"

> On Thu, Jun 20, 2019 at 3:19 AM David J. Birke  
wrote:
>> 
>> Dear R Core Team,
>> 
>> First of all, thank you for your amazing work on developing and
>> maintaining this wonderful language.
>> 
>> I just stumbled upon the following behavior in R version 3.6.0:
>> 
>> format(9.91, digits = 2, nsmall = 2)
>> format(9.99, digits = 2, nsmall = 2)
>> 
>> yield "9.91" and " 9.99" with an extraneous whitespace.
>> 
>> My expected output for the second command is "9.99".
>> 
>> I have not found anything explaining the whitespace in the help files.
>> Therefore, I am writing to report this behavior as a possible bug.
>> 
>> Best wishes,
>> David
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel



> -- 
> Sarah Goslee (she/her)
> http://www.numberwright.com

> __
> 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] base::format adds extraneous whitespace for some inputs

2019-06-20 Thread Sarah Goslee
I can reproduce this.

It has to do with whether the value rounds down to 9 or up to 10, and
thus needs another space, I think. I agree that it shouldn't happen,
but at least you can get rid of the space by using trim = TRUE.

# rounds to 9 vs 10

format(9.95, digits = 2)
format(9.96, digits = 2)

format(9.95, digits = 2, nsmall = 2)
format(9.96, digits = 2, nsmall = 2)

format(9.95, digits = 2, nsmall = 2, trim=TRUE)
format(9.96, digits = 2, nsmall = 2, trim=TRUE)

# rounds to 99 vs 100

format(99.94, digits = 3)
format(99.95, digits = 3)

format(99.94, digits = 3, nsmall = 2)
format(99.95, digits = 3, nsmall = 2)

format(99.94, digits = 3, nsmall = 2, trim=TRUE)
format(99.95, digits = 3, nsmall = 2, trim=TRUE)


> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 28 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] colorout_1.2-0

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

> # rounds to 9 vs 10
>
> format(9.95, digits = 2)
[1] "9.9"
> format(9.96, digits = 2)
[1] "10"
>
> format(9.95, digits = 2, nsmall = 2)
[1] "9.95"
> format(9.96, digits = 2, nsmall = 2)
[1] " 9.96"
>
> format(9.95, digits = 2, nsmall = 2, trim=TRUE)
[1] "9.95"
> format(9.96, digits = 2, nsmall = 2, trim=TRUE)
[1] "9.96"
>
> # rounds to 99 vs 100
>
> format(99.94, digits = 3)
[1] "99.9"
> format(99.95, digits = 3)
[1] "100"
>
> format(99.94, digits = 3, nsmall = 2)
[1] "99.94"
> format(99.95, digits = 3, nsmall = 2)
[1] " 99.95"
>
> format(99.94, digits = 3, nsmall = 2, trim=TRUE)
[1] "99.94"
> format(99.95, digits = 3, nsmall = 2, trim=TRUE)
[1] "99.95"

On Thu, Jun 20, 2019 at 3:19 AM David J. Birke  wrote:
>
> Dear R Core Team,
>
> First of all, thank you for your amazing work on developing and
> maintaining this wonderful language.
>
> I just stumbled upon the following behavior in R version 3.6.0:
>
> format(9.91, digits = 2, nsmall = 2)
> format(9.99, digits = 2, nsmall = 2)
>
> yield "9.91" and " 9.99" with an extraneous whitespace.
>
> My expected output for the second command is "9.99".
>
> I have not found anything explaining the whitespace in the help files.
> Therefore, I am writing to report this behavior as a possible bug.
>
> Best wishes,
> David
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Sarah Goslee (she/her)
http://www.numberwright.com

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


[Rd] base::format adds extraneous whitespace for some inputs

2019-06-20 Thread David J. Birke

Dear R Core Team,

First of all, thank you for your amazing work on developing and 
maintaining this wonderful language.


I just stumbled upon the following behavior in R version 3.6.0:

format(9.91, digits = 2, nsmall = 2)
format(9.99, digits = 2, nsmall = 2)

yield "9.91" and " 9.99" with an extraneous whitespace.

My expected output for the second command is "9.99".

I have not found anything explaining the whitespace in the help files. 
Therefore, I am writing to report this behavior as a possible bug.


Best wishes,
David

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