[Rd] negative numerics in []

2014-09-04 Thread Michael Haupt
Hello,

I'm a bit puzzled by what looks (to me) like a discrepancy between 
documentation and implementation.

The documentation for [] says this about the indices: "Numeric values are 
coerced to integer as by as.integer (and hence truncated towards zero)."

> as.integer(-3.1)
[1] -3

Good. But:

> x <- c(1,2,3)
> x[-3.1]
[1] 1 2 3

Given the documentation, I'd have expected a result of "[1] 1 2", because -3.1 
should be coerced to -3 (by virtue of as.integer).

What bit do I not get? (I'm using R 3.1.1, if that matters.)

Best,

Michael

-- 
Dr. Michael Haupt
Principal Member of Technical Staff
Phone: +49 331 200 7277, Fax: +49 331 200 7561
Oracle Labs
Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany

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


[Rd] R CMD check --as-cran does not show all error messages.

2014-09-04 Thread Thalles
Hello, That is my first post here and I'd like to thanks everybody in
advance.

I am writing a package with some R functions and try to submit it to CRAN.
After build and check the package a number of times, I am struggling with
the fact that the CRAN people responsible for checking  packages are
replying me with some mistakes that I just do NOT get when I do the check in
my computer. With the most recent R version, i.e. 3.1.1 and the command R
CMD check --as-cran on my package I get:

* using log directory ‘/home/thalles/Music/opentraj.Rcheck’
* using R version 3.1.1 (2014-07-10)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘opentraj/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘opentraj’ version ‘1.0’
* checking CRAN incoming feasibility ... NOTE
Maintainer: ‘Thalles Silva ’
New submission
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘opentraj’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ...
OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking examples ... OK
Examples with CPU or elapsed time > 5s
   user system elapsed
Df2SpLinesDf 67.203  0.254  67.564
Df2SpLines   36.962  0.200  37.220
PlotTraj  6.802  0.048   6.860
hytraj07.lines5.641  0.049   5.699
hytraj07.linesDf  5.229  0.059   5.295
* checking PDF version of manual ... OK
NOTE: There was 1 note.

However, the people from CRAN claim that there is a error:

* checking R code for possible problems ... NOTE
PlotBgMap: no visible binding for global variable ‘canada.map’

This function 'PlotBgMap' loads this data set ‘canada.map’, that is part of
the package. And the *LazyData: yes* is set in the DESCRIPTION file. I know
that the cause of this error is because somehow, the package is not being
loaded in the NAMESPACE, but it should be there because I am using LazyData.
That is the code for the PlotBgMap function:

PlotBgMap <-function( traj, ... ) {
hySplitProj <- CRS(proj4string(traj))
canada <- spTransform(canada.map, hySplitProj)
plot(canada.map, border="white", col="lightgrey", ... )
}

I'd like to know if I am missing something in the Checking process, or if I
should do anything else to fix this error. Thanks.



--
View this message in context: 
http://r.789695.n4.nabble.com/R-CMD-check-as-cran-does-not-show-all-error-messages-tp4696489.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] negative numerics in []

2014-09-04 Thread Henrik Bengtsson
I can reproduce this.  It seems to be happen when trying to drop the
last element, e.g.

> x <- 1:3
> x[-3.1]
[1] 1 2 3
> x[-2.1]
[1] 1 3
> x[-1.1]
[1] 2 3

> x <- 1:2
> x[-2.1]
[1] 1 2
> x[-1.1]
[1] 2

> x <- 1:4
> x[-4.1]
[1] 1 2 3
> x[-3.1]
[1] 1 2 4
> x[-2.1]
[1] 1 3 4
> x[-1.1]
[1] 2 3 4

> x <- 1
> x[-1.1]
[1] 1

My *guess* (all time I have) is that it's a bug where as.integer() is
applied only *after* (silently) dropping negative indices out of
range, e.g.

> x <- 1:4
> x[-c(1:10+0.1)]
[1] 4

Here -c(4:10+0.1) are dropped because they all > length(x).

If someone wish to track this down further, the R source is available
at https://svn.r-project.org/R/trunk/ (mirrored at
https://github.com/wch/r-source).

/Henrik

On Thu, Sep 4, 2014 at 8:17 AM, Michael Haupt  wrote:
> Hello,
>
> I'm a bit puzzled by what looks (to me) like a discrepancy between 
> documentation and implementation.
>
> The documentation for [] says this about the indices: "Numeric values are 
> coerced to integer as by as.integer (and hence truncated towards zero)."
>
>> as.integer(-3.1)
> [1] -3
>
> Good. But:
>
>> x <- c(1,2,3)
>> x[-3.1]
> [1] 1 2 3
>
> Given the documentation, I'd have expected a result of "[1] 1 2", because 
> -3.1 should be coerced to -3 (by virtue of as.integer).
>
> What bit do I not get? (I'm using R 3.1.1, if that matters.)
>
> Best,
>
> Michael
>
> --
> Dr. Michael Haupt
> Principal Member of Technical Staff
> Phone: +49 331 200 7277, Fax: +49 331 200 7561
> Oracle Labs
> Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany
>
> __
> 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] negative numerics in []

2014-09-04 Thread Duncan Murdoch

On 04/09/2014 12:52 PM, Henrik Bengtsson wrote:

I can reproduce this.  It seems to be happen when trying to drop the
last element, e.g.

> x <- 1:3
> x[-3.1]
[1] 1 2 3
> x[-2.1]
[1] 1 3
> x[-1.1]
[1] 2 3

> x <- 1:2
> x[-2.1]
[1] 1 2
> x[-1.1]
[1] 2

> x <- 1:4
> x[-4.1]
[1] 1 2 3
> x[-3.1]
[1] 1 2 4
> x[-2.1]
[1] 1 3 4
> x[-1.1]
[1] 2 3 4

> x <- 1
> x[-1.1]
[1] 1

My *guess* (all time I have) is that it's a bug where as.integer() is
applied only *after* (silently) dropping negative indices out of
range, e.g.

> x <- 1:4
> x[-c(1:10+0.1)]
[1] 4

Here -c(4:10+0.1) are dropped because they all > length(x).

If someone wish to track this down further, the R source is available
at https://svn.r-project.org/R/trunk/ (mirrored at
https://github.com/wch/r-source).


The documentation in the R Language Definition states quite clearly that 
the truncation happens first, so this definitely looks like a bug.  It 
also states  "A negative out of bounds value for |i| [the index] causes 
an error", which is also not true, but it seems possible that a 
documentation change would be less disruptive than a code change.


Duncan Murdoch


/Henrik

On Thu, Sep 4, 2014 at 8:17 AM, Michael Haupt  wrote:
> Hello,
>
> I'm a bit puzzled by what looks (to me) like a discrepancy between 
documentation and implementation.
>
> The documentation for [] says this about the indices: "Numeric values are coerced 
to integer as by as.integer (and hence truncated towards zero)."
>
>> as.integer(-3.1)
> [1] -3
>
> Good. But:
>
>> x <- c(1,2,3)
>> x[-3.1]
> [1] 1 2 3
>
> Given the documentation, I'd have expected a result of "[1] 1 2", because 
-3.1 should be coerced to -3 (by virtue of as.integer).
>
> What bit do I not get? (I'm using R 3.1.1, if that matters.)
>
> Best,
>
> Michael
>
> --
> Dr. Michael Haupt
> Principal Member of Technical Staff
> Phone: +49 331 200 7277, Fax: +49 331 200 7561
> Oracle Labs
> Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany
>
> __
> 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


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


Re: [Rd] negative numerics in []

2014-09-04 Thread Bryan Hanson
Just for the sake of completeness, I raised a closely related issue back in 
2010 which my students discovered.

https://stat.ethz.ch/pipermail/r-help/2010-March/231788.html

Bryan

On Sep 4, 2014, at 11:17 AM, Michael Haupt  wrote:

> Hello,
> 
> I'm a bit puzzled by what looks (to me) like a discrepancy between 
> documentation and implementation.
> 
> The documentation for [] says this about the indices: "Numeric values are 
> coerced to integer as by as.integer (and hence truncated towards zero)."
> 
>> as.integer(-3.1)
> [1] -3
> 
> Good. But:
> 
>> x <- c(1,2,3)
>> x[-3.1]
> [1] 1 2 3
> 
> Given the documentation, I'd have expected a result of "[1] 1 2", because 
> -3.1 should be coerced to -3 (by virtue of as.integer).
> 
> What bit do I not get? (I'm using R 3.1.1, if that matters.)
> 
> Best,
> 
> Michael
> 
> -- 
> Dr. Michael Haupt
> Principal Member of Technical Staff
> Phone: +49 331 200 7277, Fax: +49 331 200 7561
> Oracle Labs
> Oracle Deutschland B.V. & Co. KG, Schiffbauergasse 14, 14467 Potsdam, Germany
> 
> __
> 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