[Bioc-devel] change names(assays(SummarizedExperiment)) w/o copy?

2014-05-07 Thread Michael Love
hi,

Is there a way that I can change the names of the assays slot of a
SummarizedExperiment, without making a new copy of the data contained
within? Assume I get an SE which has already been constructed, but no
names on the assays() SimpleList.

thanks,

Mike

 library(GenomicRanges)
  gc()
   used (Mb) gc trigger (Mb) max used (Mb)
 Ncells 1291106   691710298 91.4  1590760 85.0
 Vcells 117861991925843 14.7  1724123 13.2
  m - matrix(1:2e7, ncol=10)
  gc()
used (Mb) gc trigger  (Mb) max used  (Mb)
 Ncells  129 69.01967602 105.1  1590760  85.0
 Vcells 11178604 85.3   22482701 171.6 21178631 161.6

# made a ~75 Mb matrix

  colnames(m) - letters[1:10]
  gc()
used (Mb) gc trigger  (Mb) max used  (Mb)
 Ncells  1291149 69.01967602 105.1  1590760  85.0
 Vcells 11178679 85.3   22482701 171.6 21179851 161.6
  se - SummarizedExperiment(m)
  gc()
used (Mb) gc trigger  (Mb) max used  (Mb)
 Ncells  1302603 69.61967602 105.1  1623929  86.8
 Vcells 12189777 93.1   22482701 171.6 21179851 161.6

# so far no copying

  names(assays(se)) - counts
  gc()
used  (Mb) gc trigger  (Mb) max used  (Mb)
 Ncells  1303174  69.61967602 105.1  1623929  86.8
 Vcells 22190847 169.4   23686836 180.8 22203423 169.4

# last step made a copy

 sessionInfo()
 R Under development (unstable) (2014-05-07 r65539)
 Platform: x86_64-apple-darwin12.5.0 (64-bit)

 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] parallel  stats graphics  grDevices utils datasets  methods
 [8] base

 other attached packages:
 [1] GenomicRanges_1.17.12 GenomeInfoDb_1.1.3IRanges_1.99.13
 [4] S4Vectors_0.0.6   BiocGenerics_0.11.2

 loaded via a namespace (and not attached):
 [1] RCurl_1.95-4.1 stats4_3.2.0   XVector_0.5.6

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


Re: [Bioc-devel] names, mcols and metadata are not changed in [- operator of class Vector

2014-05-07 Thread Hervé Pagès

Hi Sebastian,

This is the expected behavior and it's motivated by how [- behaves on
ordinary vectors:

  x - setNames(1:3, LETTERS[1:3])

Then:

   x
  A B C
  1 2 3

Replacing the first two elements:

  x[2:1] - x[1:2]

Then:

   x
  A B C
  2 1 3

The names are preserved.

So we need to think of [- as an operator that touches the values of
a vector-like object without touching its structure or its attributes.
People sometimes rely on this behavior to stuff the entire object with
a given value:

  x[] - some_value

They wouldn't expect this to destroy the names or metadata cols that
are on 'x'.

Hope that makes sense,

Cheers,
H.


On 05/07/2014 11:59 AM, Sebastian Gibb wrote:

Dear all,

today I observed an unexpected behaviour (at least for me) using the [-
operator on classes that inherited Vector.
I want to change the order of some elements inside the Vector (in my use case it
is an AAStringSet object). If I use an index in [- the names, the
elementMetadata and the metadata are not replaced by their counterparts, e.g.:

###
library(IRanges)

i - IRanges(1:3, 4:6)
names(i) - LETTERS[1:3]

i
# IRanges of length 3
# start end width names
# [1] 1   4 4 A
# [2] 2   5 4 B
# [3] 3   6 4 C

i[2:1] - i[1:2]
i
# IRanges of length 3
# start end width names
# [1] 2   5 4 A
# [2] 1   4 4 B
# [3] 3   6 4 C


## names should be B, A, C; the elementMetadata and metadata are in the wrong
## order, too.
## expected output:
# IRanges of length 3
# start end width names
# [1] 2   5 4 B
# [2] 1   4 4 A
# [3] 3   6 4 C

###

I tried to figure out the reason for this and ended up with the replaceROWS
method (in {IRanges,S4Vectors}/R/Vector-class.R).
In this method the mcols, metadata and names are just restored. To be honest I
do not really understand this function.
Why is the new value first append to the original vector (`ans - c(x, value)`)
and subsequently extracted? Would a simple replace, e.g. `x[i] - value` not be
enough?

In my opinion the last three lines should restore the original metadata
*and* replace the corresponding metadata by their new counterparts.

### replaceROWS from IRanges/R/Vector-class.R
setMethod(replaceROWS, Vector,
 function(x, i, value)
 {
 idx - seq_along(x)
 i - extractROWS(setNames(idx, names(x)), i)
 ## Assuming that objects of class 'class(x)' can be combined with c().
 ans - c(x, value)
 idx[i] - length(x) + seq_len(length(value))
 ## Assuming that [ works on objects of class 'class(x)'.
 ans - ans[idx]
 ## Restore the original decoration.
 metadata(ans) - metadata(x)
 names(ans) - names(x)
 mcols(ans) - mcols(x)
 ans
 }
)
###

Kind regards,

Sebastian

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



--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Bioc-devel] change names(assays(SummarizedExperiment)) w/o copy?

2014-05-07 Thread Martin Morgan

On 05/07/2014 12:06 PM, Michael Love wrote:

hi,

Is there a way that I can change the names of the assays slot of a
SummarizedExperiment, without making a new copy of the data contained
within? Assume I get an SE which has already been constructed, but no
names on the assays() SimpleList.


Hi Mike --

  names(assays(se)) = counts

extracts the assays from se, then applies the names to the SimpleList, then 
re-assigns the SimpleList to the SummarizedExperiment. The memory copy (of big 
data) is actually in the extraction assays(se)


 m = matrix(0, 0, 0); tracemem(m)
[1] 0x3449b4e8
 se = SummarizedExperiment(m)
 a = assays(se)
tracemem[0x3449b4e8 - 0x34ef64f0]: lapply lapply lapply lapply endoapply 
endoapply assays assays


which can actually be avoided by asking for the assays without their dimnames

 a = assays(se, withDimnames=FALSE)


and from there

  names(a) = counts
  assays(se) = a

verifying that we haven't actually copied the matrix

 .Internal(inspect(assays(se, withDimnames=FALSE)[[1]]))
@3449b4e8 14 REALSXP g0c0 [NAM(2),TR,ATT] (len=0, tl=0)
ATTRIB:
  @3449b4b0 02 LISTSXP g0c0 []
TAG: @b9c778 01 SYMSXP g0c0 [LCK,gp=0x4000] dim (has value)
@3449a118 13 INTSXP g0c1 [NAM(2)] (len=2, tl=0) 0,0
 .Internal(inspect(m))
@3449b4e8 14 REALSXP g0c0 [NAM(2),TR,ATT] (len=0, tl=0)
ATTRIB:
  @3449b4b0 02 LISTSXP g0c0 []
TAG: @b9c778 01 SYMSXP g0c0 [LCK,gp=0x4000] dim (has value)
@3449a118 13 INTSXP g0c1 [NAM(2)] (len=2, tl=0) 0,0

One would hope (a) that I'd followed through on a previous promise to just apply 
the dimnames up-front, so that there is no need to use withDimnames=FALSE to 
avoid the copying (there might have been a price on the way in) and (b) that the 
following would work


  names(assays(se, withDimnames=FALSE)) = counts

it didn't

 names(assays(se, withDimnames=FALSE)) = counts
Error in slot(x, nm) :
  no slot of name withDimnames for this object of class SummarizedExperiment

but does in 1.17.13

Martin



thanks,

Mike


library(GenomicRanges)

   gc()
used (Mb) gc trigger (Mb) max used (Mb)
  Ncells 1291106   691710298 91.4  1590760 85.0
  Vcells 117861991925843 14.7  1724123 13.2
   m - matrix(1:2e7, ncol=10)
   gc()
 used (Mb) gc trigger  (Mb) max used  (Mb)
  Ncells  129 69.01967602 105.1  1590760  85.0
  Vcells 11178604 85.3   22482701 171.6 21178631 161.6

# made a ~75 Mb matrix

   colnames(m) - letters[1:10]
   gc()
 used (Mb) gc trigger  (Mb) max used  (Mb)
  Ncells  1291149 69.01967602 105.1  1590760  85.0
  Vcells 11178679 85.3   22482701 171.6 21179851 161.6
   se - SummarizedExperiment(m)
   gc()
 used (Mb) gc trigger  (Mb) max used  (Mb)
  Ncells  1302603 69.61967602 105.1  1623929  86.8
  Vcells 12189777 93.1   22482701 171.6 21179851 161.6

# so far no copying

   names(assays(se)) - counts
   gc()
 used  (Mb) gc trigger  (Mb) max used  (Mb)
  Ncells  1303174  69.61967602 105.1  1623929  86.8
  Vcells 22190847 169.4   23686836 180.8 22203423 169.4

# last step made a copy


sessionInfo()

  R Under development (unstable) (2014-05-07 r65539)
  Platform: x86_64-apple-darwin12.5.0 (64-bit)

  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] parallel  stats graphics  grDevices utils datasets  methods
  [8] base

  other attached packages:
  [1] GenomicRanges_1.17.12 GenomeInfoDb_1.1.3IRanges_1.99.13
  [4] S4Vectors_0.0.6   BiocGenerics_0.11.2

  loaded via a namespace (and not attached):
  [1] RCurl_1.95-4.1 stats4_3.2.0   XVector_0.5.6

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




--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [Bioc-devel] names, mcols and metadata are not changed in [- operator of class Vector

2014-05-07 Thread Sebastian Gibb
Hi Hervé,

thanks for the explanation. I never recognized that this happens with ordinary
vectors, too.

Of course, I see that it would be a bad style to overload [- for my own
class to behave like I want to.

So I need to update the metadata manually.

Kind regards,

Sebastian


On 2014-05-07 20:18:58, hpa...@fhcrc.org wrote:
 Hi Sebastian,

 This is the expected behavior and it's motivated by how [- behaves on
 ordinary vectors:

x - setNames(1:3, LETTERS[1:3])

 Then:

 x
A B C
1 2 3

 Replacing the first two elements:

x[2:1] - x[1:2]

 Then:

 x
A B C
2 1 3

 The names are preserved.

 So we need to think of [- as an operator that touches the values of
 a vector-like object without touching its structure or its attributes.
 People sometimes rely on this behavior to stuff the entire object with
 a given value:

x[] - some_value

 They wouldn't expect this to destroy the names or metadata cols that
 are on 'x'.

 Hope that makes sense,

 Cheers,
 H.


 On 05/07/2014 11:59 AM, Sebastian Gibb wrote:
  Dear all,
 
  today I observed an unexpected behaviour (at least for me) using the [-
  operator on classes that inherited Vector.
  I want to change the order of some elements inside the Vector (in my use 
  case it
  is an AAStringSet object). If I use an index in [- the names, the
  elementMetadata and the metadata are not replaced by their counterparts, 
  e.g.:
 
  ###
  library(IRanges)
 
  i - IRanges(1:3, 4:6)
  names(i) - LETTERS[1:3]
 
  i
  # IRanges of length 3
  # start end width names
  # [1] 1   4 4 A
  # [2] 2   5 4 B
  # [3] 3   6 4 C
 
  i[2:1] - i[1:2]
  i
  # IRanges of length 3
  # start end width names
  # [1] 2   5 4 A
  # [2] 1   4 4 B
  # [3] 3   6 4 C
 
 
  ## names should be B, A, C; the elementMetadata and metadata are in the 
  wrong
  ## order, too.
  ## expected output:
  # IRanges of length 3
  # start end width names
  # [1] 2   5 4 B
  # [2] 1   4 4 A
  # [3] 3   6 4 C
 
  ###
 
  I tried to figure out the reason for this and ended up with the 
  replaceROWS
  method (in {IRanges,S4Vectors}/R/Vector-class.R).
  In this method the mcols, metadata and names are just restored. To be 
  honest I
  do not really understand this function.
  Why is the new value first append to the original vector (`ans - c(x, 
  value)`)
  and subsequently extracted? Would a simple replace, e.g. `x[i] - value` 
  not be
  enough?
 
  In my opinion the last three lines should restore the original metadata
  *and* replace the corresponding metadata by their new counterparts.
 
  ### replaceROWS from IRanges/R/Vector-class.R
  setMethod(replaceROWS, Vector,
   function(x, i, value)
   {
   idx - seq_along(x)
   i - extractROWS(setNames(idx, names(x)), i)
   ## Assuming that objects of class 'class(x)' can be combined with 
  c().
   ans - c(x, value)
   idx[i] - length(x) + seq_len(length(value))
   ## Assuming that [ works on objects of class 'class(x)'.
   ans - ans[idx]
   ## Restore the original decoration.
   metadata(ans) - metadata(x)
   names(ans) - names(x)
   mcols(ans) - mcols(x)
   ans
   }
  )
  ###
 
  Kind regards,
 
  Sebastian
 
  ___
  Bioc-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/bioc-devel
 

 --
 Hervé Pagès

 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024

 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319

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


[Bioc-devel] Tracking Current release (http://www.bioconductor.org/packages/current redirect to http://www.bioconductor.org/packages/2.14)

2014-05-07 Thread Don Armstrong
I maintain a collection of Debian packages of CRAN and BioC[1] for
public use; currently, whenever BioC makes a new release, it requires
manual intervention for me to point at the new release location.

It would be helpful if there was a
http://www.bioconductor.org/packages/current redirect to the current
release, or if there was another easily parsable method to obtain the
current bioC release version.

FWICT, neither http://bioconductor.org/getBioC.R nor
http://bioconductor.org/biocLite.R encode that information either,[2]
unless that's what CURRENT_R_DEVEL_VERSION - 2.14.0 is supposed to
be.


1: http://debian-r.debian.net/

2: I should also point out that the current methodology of installing
BioC using code from a remote host is problematic as it exposes users to
MITM attacks because it is never checked for authenticity via PGP or at
the very least, SSL. As such, sourcing that script and using variables
populated by it isn't really acceptable.

-- 
Don Armstrong  http://www.donarmstrong.com

I never until now realized that the primary job of any emoticon is to
say excuse me, that didn't make any sense. ;-P
 -- Cory Doctorow

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


Re: [Bioc-devel] Tracking Current release (http://www.bioconductor.org/packages/current redirect to http://www.bioconductor.org/packages/2.14)

2014-05-07 Thread Martin Morgan

Hi Don --

On 05/07/2014 06:21 PM, Don Armstrong wrote:

I maintain a collection of Debian packages of CRAN and BioC[1] for
public use; currently, whenever BioC makes a new release, it requires
manual intervention for me to point at the new release location.

It would be helpful if there was a
http://www.bioconductor.org/packages/current redirect to the current
release, or if there was another easily parsable method to obtain the
current bioC release version.


Bioconductor releases are tied to R versions and the 'current' Bioc for a 
particular R, in a brand new installation, is


  source(http://bioconductor.org/biocLite.R;)
  biocVersion()

(this is BiocInstaller::biocVersion(), where the biocLite.R script has arranged, 
modulo MITM concerns below, to install the version of the BiocInstaller package 
relevant to your version of R). I personally think of this as the canonical 
location, but...


http://bioconductor.org/packages/release goes to the current release 
'biocViews', with packages under release/ being the current release versions. 
http://bioconductor.org/bioc-version is probably what you'll end up using 
(though I believe it's hand curated), and 
tools:::.BioC_version_associated_with_R_version (this is a function in R-3.1) 
gives the version that R thinks is the current BioC version (this can become 
stale, e.g., R-3.0.1 was released when BioC-2.12 was the current version, but 
part way through the R point release BioC 2.13 became available [or at least, 
that's how I remember it]).	



FWICT, neither http://bioconductor.org/getBioC.R nor
http://bioconductor.org/biocLite.R encode that information either,[2]
unless that's what CURRENT_R_DEVEL_VERSION - 2.14.0 is supposed to
be.


1: http://debian-r.debian.net/

2: I should also point out that the current methodology of installing
BioC using code from a remote host is problematic as it exposes users to
MITM attacks because it is never checked for authenticity via PGP or at
the very least, SSL. As such, sourcing that script and using variables
populated by it isn't really acceptable.


Of course this is a valid concern and we can work toward a more secure approach.

Perhaps I could take the opportunity to ask a naive question about debian binary 
distributions of R. What is the directory into which packages are installed by 
sudo? In particular, are they unversioned, /usr/lib/R/library etc, as opposed to 
say /usr/lib/R-3.1/library ? I'm asking because a number of users seem to show 
up with say R-3.1 reporting a mix of R-3.1 and R-3.0.2 packages, usually to ill 
effect; this is not necessarily likely for user-installed packages, because the 
system directories won't be writeable and R will prompt with a versioned 
directory ~/R/x86_64-unknown-linux-gnu-library/3.1 as the location to install 
libraries. I'm wondering if mixed package versions would happen if their package 
manager failed to remove previously installed packages from the 
/usr/lib/R/library directory, or if the user installed multiple versions of R. 
Of course this could merely reflect users installing R without the help of 
package managers, and either way it might point to changes in the way R installs 
itself.


Martin






--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [Bioc-devel] Tracking Current release (http://www.bioconductor.org/packages/current redirect to http://www.bioconductor.org/packages/2.14)

2014-05-07 Thread Dan Tenenbaum


- Original Message -
 From: Martin Morgan mtmor...@fhcrc.org
 To: bioc-devel@r-project.org
 Sent: Wednesday, May 7, 2014 10:07:10 PM
 Subject: Re: [Bioc-devel] Tracking Current release 
 (http://www.bioconductor.org/packages/current redirect to
 http://www.bioconductor.org/packages/2.14)
 
 Hi Don --
 
 On 05/07/2014 06:21 PM, Don Armstrong wrote:
  I maintain a collection of Debian packages of CRAN and BioC[1] for
  public use; currently, whenever BioC makes a new release, it
  requires
  manual intervention for me to point at the new release location.
 
  It would be helpful if there was a
  http://www.bioconductor.org/packages/current redirect to the
  current
  release, or if there was another easily parsable method to obtain
  the
  current bioC release version.
 
 Bioconductor releases are tied to R versions and the 'current' Bioc
 for a
 particular R, in a brand new installation, is
 
source(http://bioconductor.org/biocLite.R;)
biocVersion()
 
 (this is BiocInstaller::biocVersion(), where the biocLite.R script
 has arranged,
 modulo MITM concerns below, to install the version of the
 BiocInstaller package
 relevant to your version of R). I personally think of this as the
 canonical
 location, but...
 
 http://bioconductor.org/packages/release goes to the current release
 'biocViews', with packages under release/ being the current release
 versions.
 http://bioconductor.org/bioc-version is probably what you'll end up
 using
 (though I believe it's hand curated), and


This is automatically generated, as is
http://bioconductor.org/js/versions.js
which also includes the devel version number.

Dan

 tools:::.BioC_version_associated_with_R_version (this is a function
 in R-3.1)
 gives the version that R thinks is the current BioC version (this can
 become
 stale, e.g., R-3.0.1 was released when BioC-2.12 was the current
 version, but
 part way through the R point release BioC 2.13 became available [or
 at least,
 that's how I remember it]).
 
  FWICT, neither http://bioconductor.org/getBioC.R nor
  http://bioconductor.org/biocLite.R encode that information
  either,[2]
  unless that's what CURRENT_R_DEVEL_VERSION - 2.14.0 is supposed
  to
  be.
 
 
  1: http://debian-r.debian.net/
 
  2: I should also point out that the current methodology of
  installing
  BioC using code from a remote host is problematic as it exposes
  users to
  MITM attacks because it is never checked for authenticity via PGP
  or at
  the very least, SSL. As such, sourcing that script and using
  variables
  populated by it isn't really acceptable.
 
 Of course this is a valid concern and we can work toward a more
 secure approach.
 
 Perhaps I could take the opportunity to ask a naive question about
 debian binary
 distributions of R. What is the directory into which packages are
 installed by
 sudo? In particular, are they unversioned, /usr/lib/R/library etc, as
 opposed to
 say /usr/lib/R-3.1/library ? I'm asking because a number of users
 seem to show
 up with say R-3.1 reporting a mix of R-3.1 and R-3.0.2 packages,
 usually to ill
 effect; this is not necessarily likely for user-installed packages,
 because the
 system directories won't be writeable and R will prompt with a
 versioned
 directory ~/R/x86_64-unknown-linux-gnu-library/3.1 as the location to
 install
 libraries. I'm wondering if mixed package versions would happen if
 their package
 manager failed to remove previously installed packages from the
 /usr/lib/R/library directory, or if the user installed multiple
 versions of R.
 Of course this could merely reflect users installing R without the
 help of
 package managers, and either way it might point to changes in the way
 R installs
 itself.
 
 Martin
 
 
 
 
 --
 Computational Biology / Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N.
 PO Box 19024 Seattle, WA 98109
 
 Location: Arnold Building M1 B861
 Phone: (206) 667-2793
 
 ___
 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


[Rd] Problem running checks after building R-patched

2014-05-07 Thread Berend Hasselman


I am compiling the latest R-patched (Revision: 65533) Ubuntu Lucid (10.04).

Building succeeds but make check stops with an error.
The output in the terminal from make check:

Testing examples for package ‘base’
Testing examples for package ‘tools’
Error: testing 'tools' failed
Execution halted
make[3]: *** [test-Examples-Base] Error 1
make[2]: *** [test-Examples] Error 2
make[1]: *** [test-all-basics] Error 1
make: *** [check] Error 2

The last lines in  the output of tests/Examples/tools-Ex.Rout.fail are

 ### ** Examples
 
 gVigns - pkgVignettes(grid)
 ## Don't show: 
  `%=f=%` - function(a, b) normalizePath(a) == normalizePath(b)
  with(gVigns,
+   stopifnot(engines == utils::Sweave,
+ pkgdir %=f=% system.file(package=grid),
+ dir%=f=% system.file(package=grid, doc),
+ (n. - length(docs)) = 12, # have 13 
+ n. == length(names), n. == length(engines),
+ length(msg) == 0) ) # as it is a 'base' package
Error: (n. - length(docs)) = 12 is not TRUE
Execution halted

How do I fix this, if possible?

Berend

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


Re: [Rd] Problem running checks after building R-patched

2014-05-07 Thread Martin Maechler
 Berend Hasselman b...@xs4all.nl
 on Wed, 7 May 2014 09:24:46 +0200 writes:

 I am compiling the latest R-patched (Revision: 65533) Ubuntu Lucid 
(10.04).

 Building succeeds but make check stops with an error.
 The output in the terminal from make check:

 Testing examples for package ‘base’
 Testing examples for package ‘tools’
 Error: testing 'tools' failed
 Execution halted
 make[3]: *** [test-Examples-Base] Error 1
 make[2]: *** [test-Examples] Error 2
 make[1]: *** [test-all-basics] Error 1
 make: *** [check] Error 2

 The last lines in  the output of tests/Examples/tools-Ex.Rout.fail are

 ### ** Examples
 
 gVigns - pkgVignettes(grid)
 ## Don't show: 
 `%=f=%` - function(a, b) normalizePath(a) == normalizePath(b)
 with(gVigns,
 +   stopifnot(engines == utils::Sweave,
 + pkgdir %=f=% system.file(package=grid),
 + dir%=f=% system.file(package=grid, doc),
 + (n. - length(docs)) = 12, # have 13 
 + n. == length(names), n. == length(engines),
 + length(msg) == 0) ) # as it is a 'base' package
 Error: (n. - length(docs)) = 12 is not TRUE
 Execution halted

 How do I fix this, if possible?
 Berend

Well, as it works correctly for others,
why don't you execute the above code in your (self installed ?) version
of R, and find out why -- I think -- the vignettes of grid were
not built / installed correctly ?

Martin

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


Re: [Rd] Problem running checks after building R-patched

2014-05-07 Thread Berend Hasselman

On 07-05-2014, at 11:23, Martin Maechler maech...@stat.math.ethz.ch wrote:

 Berend Hasselman b...@xs4all.nl
on Wed, 7 May 2014 09:24:46 +0200 writes:
 
 I am compiling the latest R-patched (Revision: 65533) Ubuntu Lucid (10.04).
 
 Building succeeds but make check stops with an error.
 The output in the terminal from make check:
 
 Testing examples for package ‘base’
 Testing examples for package ‘tools’
 Error: testing 'tools' failed
 Execution halted
 make[3]: *** [test-Examples-Base] Error 1
 make[2]: *** [test-Examples] Error 2
 make[1]: *** [test-all-basics] Error 1
 make: *** [check] Error 2
 
 The last lines in  the output of tests/Examples/tools-Ex.Rout.fail are
 
 ### ** Examples
 
 gVigns - pkgVignettes(grid)
 ## Don't show: 
 `%=f=%` - function(a, b) normalizePath(a) == normalizePath(b)
 with(gVigns,
 +   stopifnot(engines == utils::Sweave,
 + pkgdir %=f=% system.file(package=grid),
 + dir%=f=% system.file(package=grid, doc),
 + (n. - length(docs)) = 12, # have 13 
 + n. == length(names), n. == length(engines),
 + length(msg) == 0) ) # as it is a 'base' package
 Error: (n. - length(docs)) = 12 is not TRUE
 Execution halted
 
 How do I fix this, if possible?
 Berend
 
 Well, as it works correctly for others,
 why don't you execute the above code in your (self installed ?) version
 of R, and find out why -- I think -- the vignettes of grid were
 not built / installed correctly ?
 
 Martin


I have the release version R-3.1.0 installed (built and checked with NO error 
messages).

I don't have pdflatex installed; that is detected by configure.

I have found a difference between ……/tests/Examples/tools-Ex.R in R-3.1.0 and 
R-patched.
After running this command

 diff R-3.1.0-build/tests/Examples/tools-Ex.R 
R-patched-build/tests/Examples/tools-Ex.R  
diff-3.1.0-3.1.0patched-tools-Ex.R.txt

the file with the differences contains this:

155a156,184
 nameEx(buildVignettes)
 ### * buildVignettes
 
 flush(stderr()); flush(stdout())
 
 ### Name: buildVignettes
 ### Title: List and Build Package Vignettes
 ### Aliases: buildVignettes pkgVignettes
 ### Keywords: utilities documentation
 
 ### ** Examples
 
 gVigns - pkgVignettes(grid)
 ## Don't show: 
  `%=f=%` - function(a, b) normalizePath(a) == normalizePath(b)
  with(gVigns,
   stopifnot(engines == utils::Sweave,
 pkgdir %=f=% system.file(package=grid),
 dir%=f=% system.file(package=grid, doc),
 (n. - length(docs)) = 12, # have 13 
 n. == length(names), n. == length(engines),
 length(msg) == 0) ) # as it is a 'base' package
 ## End Don't show
 stopifnot(grid %in% gVigns$names,
   inherits(gVigns, pkgVignettes))
 
 
 
 cleanEx()

which would indicate that tool-Ex.R contains an additional test.

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Therneau, Terry M., Ph.D.

Hadley asked about the Blue book; my shelf still has the earlier brown book
   Becker and Chambers, 1984, S: An interactive environment for data analysis 
and graphics.

The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

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


[Rd] historical significance of Pr(Chisq) 2.2e-16

2014-05-07 Thread Michael Friendly
Where does the value 2.2e-16 come from in p-values for chisq tests such 
as those

reported below?

 Anova(cm.mod2)
Analysis of Deviance Table (Type II tests)

Response: Freq
LR Chisq Df Pr(Chisq)
B 11026.2 1  2.2e-16 ***
W 7037.5 1  2.2e-16 ***
Age 886.6 8  2.2e-16 ***
B:W 3025.2 1  2.2e-16 ***
B:Age 1130.4 8  2.2e-16 ***
W:Age 332.9 8  2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [Rd] historical significance of Pr(Chisq) 2.2e-16

2014-05-07 Thread John Nolan
Presumably from

 .Machine$double.eps
[1] 2.220446e-16

Whether this means the tail probability is actually that
small, or that the routine that computes it can't get
any more accuracy than that, you'll have to dig deeper.

John
 ..
 John P. Nolan
 Math/Stat Department
 227 Gray Hall,   American University
 4400 Massachusetts Avenue, NW
 Washington, DC 20016-8050

 jpno...@american.edu   voice: 202.885.3140  
 web: academic2.american.edu/~jpnolan
 ..


-r-devel-boun...@r-project.org wrote: - 
To: r-devel r-devel@r-project.org
From: Michael Friendly 
Sent by: r-devel-boun...@r-project.org
Date: 05/07/2014 10:02AM
Subject: [Rd] historical significance of Pr(Chisq)  2.2e-16

Where does the value 2.2e-16 come from in p-values for chisq tests such 
as those
reported below?

  Anova(cm.mod2)
Analysis of Deviance Table (Type II tests)

Response: Freq
LR Chisq Df Pr(Chisq)
B 11026.2 1  2.2e-16 ***
W 7037.5 1  2.2e-16 ***
Age 886.6 8  2.2e-16 ***
B:W 3025.2 1  2.2e-16 ***
B:Age 1130.4 8  2.2e-16 ***
W:Age 332.9 8  2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
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] historical significance of Pr(Chisq) 2.2e-16

2014-05-07 Thread Jari Oksanen
See ?format.pval

cheers, jari oksanen

From: r-devel-boun...@r-project.org [r-devel-boun...@r-project.org] on behalf 
of Michael Friendly [frien...@yorku.ca]
Sent: 07 May 2014 17:02
To: r-devel
Subject: [Rd] historical significance of Pr(Chisq)  2.2e-16

Where does the value 2.2e-16 come from in p-values for chisq tests such
as those
reported below?

  Anova(cm.mod2)
Analysis of Deviance Table (Type II tests)

Response: Freq
LR Chisq Df Pr(Chisq)
B 11026.2 1  2.2e-16 ***
W 7037.5 1  2.2e-16 ***
Age 886.6 8  2.2e-16 ***
B:W 3025.2 1  2.2e-16 ***
B:Age 1130.4 8  2.2e-16 ***
W:Age 332.9 8  2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
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] precedence (was 'historical NA question')

2014-05-07 Thread luke-tierney

On Wed, 7 May 2014, Therneau, Terry M., Ph.D. wrote:


Hadley asked about the Blue book; my shelf still has the earlier brown book
  Becker and Chambers, 1984, S: An interactive environment for data analysis 
and graphics.


The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment



which did lead to some head scratching after plotting exp(-x^2) :-)

luke


Terry Therneau

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



--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread John Chambers

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown book
Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3 
of S (the blue book) was back-compatible with earlier versions.  We 
gave users some help in getting on the road to converting, that was 
all (see Appendix 4 to the blue book).


For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


[Rd] yinch() is NOT nonsense with log='y'

2014-05-07 Thread Spencer Graves
  May I request a modest change in the documentation and warning 
for xinch, yinch, and xyinch?



  Consider the following example:


 plot(1:2, log='y')
 yinch(1)
[1] 0.1961134
Warning message:
In yinch(1) : y log scale:  yinch() is nonsense


  In fact, in this environment, yinch(y) translates a vertical 
displacement of y inches into the corresponding change in the log10 
scale.  For a realistic example of such a use, see the first example of 
the current R-Forge version of the new animate function in the Ecfun 
package:  This places the Rlogo on a plot(..., log='y') without distortion.



  Thanks,
  Spencer Graves

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


Re: [Rd] Historical NA question (Herv? Pag?s)

2014-05-07 Thread Georgi Boshnakov
Equivalence certainly does not mean that literally replacing some text will 
not change the result. 

From R language definition, p. 11:

 Except for the syntax, there is no difference between applying an operator 
 and calling a
function. In fact, x + y can equivalently be written ‘+‘(x, y). Notice that 
since ‘+’ is a nonstandard
function name, it needs to be quoted.

A doubt that anybody would interpret the above as implying that the following 
expressions should be equivalent:
 2 * 2 + 2

 2  *  +(2,2)

I believe that S's %xxx% notation predates Mathematica's generic infix, ~XXX~, 
notation, which also has high priority, independent of the meaning of the 
symbol XXX. 


--
Dr Georgi Boshnakov   tel: (+44) (0)161 306 3684
School of Mathematics fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester  email: georgi.boshna...@manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK


Date: Tue, 06 May 2014 13:57:14 -0700
From: Herv? Pag?s hpa...@fhcrc.org
To: William Dunlap wdun...@tibco.com
Cc: Michael Friendly frien...@yorku.ca,   r-devel@r-project.org
r-devel@r-project.org
Subject: Re: [Rd] Historical NA question
Message-ID: 53694caa.3080...@fhcrc.org
Content-Type: text/plain; charset=UTF-8; format=flowed

On 05/06/2014 01:44 PM, William Dunlap wrote:
 Run the following function over the output of
 parse(yourSourceCode.R) to edit the parse tree:

 inToIsElement - function (expr)
 {
  # expr should be an expression or a call, not a function.
  # The output of parse(keep.source=FALSE) or quote() is good.
  if (is.call(expr)  identical(expr[[1]], as.name(%in%))) {
  expr[[1]] - as.name(is.element)
  }
  if (is.recursive(expr)) {
  for(i in seq_along(expr)) {
  expr[[i]] - Recall(expr[[i]])
  }
 }
 expr
 }

 E.g.,
 txt - function(els, negSet, posSet){
 + -els %in% negSet  # commentary
 +  els %in% posSet
 + }
 inToIsElement(parse(text=txt, keep.source=FALSE))[[1]]
 function(els, negSet, posSet) {
  is.element(-els, negSet)  is.element(els, posSet)
 }

 It assumes that you didn't make any precedence errors with %in%.

Thanks Bill. I appreciate that you are really trying to help me with my
precedence problem. Maybe I should clarify that I can live with it
though. Anyway, it's always good to know how to make substitutions in
the parse tree.

Cheers,
H.


 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Tue, May 6, 2014 at 1:28 PM, Herv? Pag?s hpa...@fhcrc.org wrote:
 On 05/06/2014 01:15 PM, William Dunlap wrote:

 In your example els%in%set gave the same result as
 is.element(els,set), but because of precedence issues putting a unary
 minus in front caused them to be given different inputs - one got -els
 and the other got just els for the first argument.


 So you confirm that to use your solution (i.e. replace my use of
 'els%in%set' with 'is.element(els,set)') I need to think about
 precedence?


 To change one to
 the other you have to edit the parsed expression, not the text.  If
 you used is.element in the first place you would avoid precedence
 issues.


 If you ... in the first place. A, but that's not what I did. So
 that doesn't help me.

 H.


   (I avoid creating %xxx% functions  because the precedence is
 not often what I want.)
 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Tue, May 6, 2014 at 1:06 PM, Herv? Pag?s hpa...@fhcrc.org wrote:

 On 05/06/2014 12:36 PM, William Dunlap wrote:


 When does els%in%set give a different result than is.element(els,set)?
 I assumed they were copied form S+, where they are the same except
 for argument names, but I may be wrong.



  els - 2:1
  set - 1:6
  - els%in%set
 [1] FALSE FALSE
  - is.element(els,set)
 [1] -1 -1

 So following your advice doesn't really help me leave my precedence
 problems behind.


 H.

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Tue, May 6, 2014 at 12:23 PM, Herv? Pag?s hpa...@fhcrc.org wrote:


 On 05/06/2014 08:54 AM, William Dunlap wrote:



 You can also use is.element(els,set) instead of the equivalent
 els%in%set




 No they are not *equivalent*. Equivalent means you could substitute
 one by the other in your code without changing its behavior.

 H.

 and leave your precedence problems behind.
 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Mon, May 5, 2014 at 10:35 PM, peter dalgaard pda...@gmail.com
 wrote:




 On 06 May 2014, at 01:05 , Herv? Pag?s hpa...@fhcrc.org wrote:


 BTW, that %in% has precedence over arithmetic operations is
 surprising,
 error-prone, and doesn't cover any reasonable use case (who needs to
 multiply the logical vector returned by %in% by some value?) but
 that's
 another story:




 The point here is that the %foo% operators all have the _same_
 precedence. In principle, they can be user-coded, and there is no way
 to
 express what precedence is desirable. It may 

Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès

No big deal. These things can be tricky:

 https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)

H.

On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Simon Urbanek
On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:

 No big deal. These things can be tricky:
 
 https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html
 
 Sorry I couldn't resist ;-)
 

Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant? Is there a way to express a negative 
constant in R? Hmm… 


 On 05/07/2014 09:16 AM, John Chambers wrote:
 On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:
 Hadley asked about the Blue book; my shelf still has the earlier brown
 book
Becker and Chambers, 1984, S: An interactive environment for data
 analysis and graphics.
 
 Historically interesting, but there was never a guarantee that Version 3
 of S (the blue book) was back-compatible with earlier versions.  We
 gave users some help in getting on the road to converting, that was
 all (see Appendix 4 to the blue book).
 
 For that one brief moment, we felt free to innovate.
 
 John
 
 
 The manual page for precedence is
 
 $   component select
 %x  special operator
 -   unary minus
 :   sequence operator
 ^ **exponentiation
 * / mult/div
 + - add/sub
   = = == != logical
 !   not
  | and/or
 - -   assignment
 
 Terry Therneau
 
 __
 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
 
 -- 
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 
 __
 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] historical significance of Pr(Chisq) 2.2e-16

2014-05-07 Thread William Dunlap
It may come a time before the pchisq() function had the lower.tail
argument.  In those days you had the compute the upper tail as
1-pchisq(x2, df).  For any eps2.2e-16 (.Machine$double.eps), 1-eps==1
so 1-(1-eps)==0 so you would get, e.g.,
   1-pchisq(100,2)
  [1] 0
and people would say 'but the p-value is not 0: it may be very small
but not zero' so anova's printing functions would say 2.2e-16 to
mollify them.

Now we have the lower.tail=FALSE argument
   pchisq(100,2,lower.tail=FALSE)
  [1] 1.92875e-22
and don't need the 2.2e-16 but no one has seen fit to change things.
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, May 7, 2014 at 7:02 AM, Michael Friendly frien...@yorku.ca wrote:
 Where does the value 2.2e-16 come from in p-values for chisq tests such as
 those
 reported below?

 Anova(cm.mod2)
 Analysis of Deviance Table (Type II tests)

 Response: Freq
 LR Chisq Df Pr(Chisq)
 B 11026.2 1  2.2e-16 ***
 W 7037.5 1  2.2e-16 ***
 Age 886.6 8  2.2e-16 ***
 B:W 3025.2 1  2.2e-16 ***
 B:Age 1130.4 8  2.2e-16 ***
 W:Age 332.9 8  2.2e-16 ***
 ---
 Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.  Chair, Quantitative Methods
 York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA

 __
 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] precedence (was 'historical NA question')

2014-05-07 Thread peter dalgaard

On 07 May 2014, at 21:52 , Simon Urbanek simon.urba...@r-project.org wrote:

 On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:
 
 No big deal. These things can be tricky:
 
 https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html
 
 Sorry I couldn't resist ;-)
 
 
 Yeah, but that's just yet another trip down the rabbit hole - why is -2 
 parsed as `-`(2) and not a single constant? Is there a way to express a 
 negative constant in R? Hmm… 
 

It's painful, but

 bquote(.(-2)^2)
-2^2
 eval(bquote(.(-2)^2))
[1] 4
 bquote(.(-2)^2)[[2]]
[1] -2
 mode(bquote(.(-2)^2)[[2]])
[1] numeric

The difficulty is that the tokenizer, which recognizes language elements before 
the parser goes to work on the grammatical structure, is unable to distinguish 
the -2 in -2 + 2 from the one in -2 ^ y. And since constants are generated 
by the tokenizer, negative ones are not generated. I don't think it is 
completely out of reach for the parser to recognize the pattern unary minus a 
numeric constant and fold it into a constant of the opposite sign, but I'm not 
volunteering... (and anyways, it is part of the bigger issue of general 
constant folding --- I suppose that Luke has a handle on that.)


 
 On 05/07/2014 09:16 AM, John Chambers wrote:
 On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:
 Hadley asked about the Blue book; my shelf still has the earlier brown
 book
   Becker and Chambers, 1984, S: An interactive environment for data
 analysis and graphics.
 
 Historically interesting, but there was never a guarantee that Version 3
 of S (the blue book) was back-compatible with earlier versions.  We
 gave users some help in getting on the road to converting, that was
 all (see Appendix 4 to the blue book).
 
 For that one brief moment, we felt free to innovate.
 
 John
 
 
 The manual page for precedence is
 
 $   component select
 %x  special operator
 -   unary minus
 :   sequence operator
 ^ **exponentiation
 * / mult/div
 + - add/sub
   = = == != logical
 !   not
  | and/or
 - -   assignment
 
 Terry Therneau
 
 __
 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
 
 -- 
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 
 __
 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

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès

On 05/07/2014 12:52 PM, Simon Urbanek wrote:

On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant?


You wouldn't want -2 to be parsed as a single constant exactly for
the reason that you wouldn't want -2^2 to return 4. Having -2^2 treated
the same way as -x^2 is a sane feature.


Is there a way to express a negative constant in R? Hmm…


Maybe some people have some use cases for this (speed ?).
Personally I don't. Of course it would require a special syntax,
something that would probably be as ugly and confusing as the
L suffix used for integer constants (L means long int in C).

H.





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès

On 05/07/2014 02:01 PM, peter dalgaard wrote:


On 07 May 2014, at 21:52 , Simon Urbanek simon.urba...@r-project.org wrote:


On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant? Is there a way to express a negative 
constant in R? Hmm…



It's painful, but


bquote(.(-2)^2)

-2^2

eval(bquote(.(-2)^2))

[1] 4

bquote(.(-2)^2)[[2]]

[1] -2

mode(bquote(.(-2)^2)[[2]])

[1] numeric

The difficulty is that the tokenizer, which recognizes language elements before the parser goes to 
work on the grammatical structure, is unable to distinguish the -2 in -2 + 2 from the 
one in -2 ^ y.


Are you saying that the tokenizer could be made smarter and recognize
-2 as a token in -2 ^ y, just because you didn't put a space between
- and 2? So in -2 ^ y it would be token, but not in - 2^y.
An therefore precedence would now depend on whether there is a space
after the minus or not, or something like that? I'm confused.

H.


And since constants are generated by the tokenizer, negative ones are not generated. I 
don't think it is completely out of reach for the parser to recognize the pattern 
unary minus a numeric constant and fold it into a constant of the opposite 
sign, but I'm not volunteering... (and anyways, it is part of the bigger issue of general 
constant folding --- I suppose that Luke has a handle on that.)





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
   Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

__
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




--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Simon Urbanek

On May 7, 2014, at 5:17 PM, Hervé Pagès hpa...@fhcrc.org wrote:

 On 05/07/2014 12:52 PM, Simon Urbanek wrote:
 On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:
 
 No big deal. These things can be tricky:
 
 https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html
 
 Sorry I couldn't resist ;-)
 
 
 Yeah, but that's just yet another trip down the rabbit hole - why is -2 
 parsed as `-`(2) and not a single constant?
 
 You wouldn't want -2 to be parsed as a single constant exactly for
 the reason that you wouldn't want -2^2 to return 4. Having -2^2 treated
 the same way as -x^2 is a sane feature.
 

On what grounds? -2 is one value - negative two - and if you square it, you get 
four - so that's not even a question of precedence. It's just a matter of 
interpretation: do you see the constant -2 or do you see the constant 2 with 
unary minus? When you print -2 you get -2 - and that's not a positive constant 
with an unary minus - or is it? ;) - aaah, will we ever know … R is good at 
hiding that subtlety from us:

 a = quote(-2^2)
 b = bquote(.(-2)^2)
 a
-2^2
 b
-2^2
 eval(a)
[1] -4
 eval(b)
[1] 4


 Is there a way to express a negative constant in R? Hmm…
 
 Maybe some people have some use cases for this (speed ?).

Wrong tree ;). You kick-started the trip but failed to follow the path it takes 
into the depths of the human mind … :P (or was that computer mind? ;))

Cheers,
Simon



 Personally I don't. Of course it would require a special syntax,
 something that would probably be as ugly and confusing as the
 L suffix used for integer constants (L means long int in C).
 
 H.
 
 
 
 On 05/07/2014 09:16 AM, John Chambers wrote:
 On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:
 Hadley asked about the Blue book; my shelf still has the earlier brown
 book
Becker and Chambers, 1984, S: An interactive environment for data
 analysis and graphics.
 
 Historically interesting, but there was never a guarantee that Version 3
 of S (the blue book) was back-compatible with earlier versions.  We
 gave users some help in getting on the road to converting, that was
 all (see Appendix 4 to the blue book).
 
 For that one brief moment, we felt free to innovate.
 
 John
 
 
 The manual page for precedence is
 
 $   component select
 %x  special operator
 -   unary minus
 :   sequence operator
 ^ **exponentiation
 * / mult/div
 + - add/sub
   = = == != logical
 !   not
  | and/or
 - -   assignment
 
 Terry Therneau
 
 __
 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
 
 --
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
 
 
 
 -- 
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Simon Urbanek

On May 7, 2014, at 5:41 PM, Hervé Pagès hpa...@fhcrc.org wrote:

 On 05/07/2014 02:01 PM, peter dalgaard wrote:
 
 On 07 May 2014, at 21:52 , Simon Urbanek simon.urba...@r-project.org wrote:
 
 On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:
 
 No big deal. These things can be tricky:
 
 https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html
 
 Sorry I couldn't resist ;-)
 
 
 Yeah, but that's just yet another trip down the rabbit hole - why is -2 
 parsed as `-`(2) and not a single constant? Is there a way to express a 
 negative constant in R? Hmm…
 
 
 It's painful, but
 
 bquote(.(-2)^2)
 -2^2
 eval(bquote(.(-2)^2))
 [1] 4
 bquote(.(-2)^2)[[2]]
 [1] -2
 mode(bquote(.(-2)^2)[[2]])
 [1] numeric
 
 The difficulty is that the tokenizer, which recognizes language elements 
 before the parser goes to work on the grammatical structure, is unable to 
 distinguish the -2 in -2 + 2 from the one in -2 ^ y.
 
 Are you saying that the tokenizer could be made smarter and recognize
 -2 as a token in -2 ^ y, just because you didn't put a space between
 - and 2? So in -2 ^ y it would be token, but not in - 2^y.
 An therefore precedence would now depend on whether there is a space
 after the minus or not, or something like that? I'm confused.
 

Nope, precedence would not change at all. -2 and - 2 are two different 
things - in case you didn't realize that spaces are important, try a-2 vs 
a -2. So, again, if -2 is a value then there is no precedence issue, since 
you have only operator in  -2 ^ y namely ^. In - 2 ^ y you have two 
operators, so precedence matters.

Cheers,
Simon



 H.
 
 And since constants are generated by the tokenizer, negative ones are not 
 generated. I don't think it is completely out of reach for the parser to 
 recognize the pattern unary minus a numeric constant and fold it into a 
 constant of the opposite sign, but I'm not volunteering... (and anyways, it 
 is part of the bigger issue of general constant folding --- I suppose that 
 Luke has a handle on that.)
 
 
 
 On 05/07/2014 09:16 AM, John Chambers wrote:
 On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:
 Hadley asked about the Blue book; my shelf still has the earlier brown
 book
   Becker and Chambers, 1984, S: An interactive environment for data
 analysis and graphics.
 
 Historically interesting, but there was never a guarantee that Version 3
 of S (the blue book) was back-compatible with earlier versions.  We
 gave users some help in getting on the road to converting, that was
 all (see Appendix 4 to the blue book).
 
 For that one brief moment, we felt free to innovate.
 
 John
 
 
 The manual page for precedence is
 
 $   component select
 %x  special operator
 -   unary minus
 :   sequence operator
 ^ **exponentiation
 * / mult/div
 + - add/sub
   = = == != logical
 !   not
  | and/or
 - -   assignment
 
 Terry Therneau
 
 __
 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
 
 --
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 
 __
 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
 
 
 -- 
 Hervé Pagès
 
 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024
 
 E-mail: hpa...@fhcrc.org
 Phone:  (206) 667-5791
 Fax:(206) 667-1319
 

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Duncan Murdoch

On 07/05/2014, 5:55 PM, Simon Urbanek wrote:


On May 7, 2014, at 5:41 PM, Hervé Pagès hpa...@fhcrc.org wrote:


On 05/07/2014 02:01 PM, peter dalgaard wrote:


On 07 May 2014, at 21:52 , Simon Urbanek simon.urba...@r-project.org wrote:


On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant? Is there a way to express a negative 
constant in R? Hmm…



It's painful, but


bquote(.(-2)^2)

-2^2

eval(bquote(.(-2)^2))

[1] 4

bquote(.(-2)^2)[[2]]

[1] -2

mode(bquote(.(-2)^2)[[2]])

[1] numeric

The difficulty is that the tokenizer, which recognizes language elements before the parser goes to 
work on the grammatical structure, is unable to distinguish the -2 in -2 + 2 from the 
one in -2 ^ y.


Are you saying that the tokenizer could be made smarter and recognize
-2 as a token in -2 ^ y, just because you didn't put a space between
- and 2? So in -2 ^ y it would be token, but not in - 2^y.
An therefore precedence would now depend on whether there is a space
after the minus or not, or something like that? I'm confused.



Nope, precedence would not change at all. -2 and - 2 are two different things - in case you didn't realize that spaces are 
important, try a-2 vs a -2. So, again, if -2 is a value then there is no precedence issue, since you have only operator in  
-2 ^ y namely ^. In - 2 ^ y you have two operators, so precedence matters.


Is there a language where - 2^2 gives a different answer than -2^2? 
 (Substitute ** or any other exponentiation operator for ^ if you 
like.)  This is important, because I'd like to avoid ever attempting any 
important calculation in that language.


Duncan Murdoch


Cheers,
Simon




H.


And since constants are generated by the tokenizer, negative ones are not generated. I 
don't think it is completely out of reach for the parser to recognize the pattern 
unary minus a numeric constant and fold it into a constant of the opposite 
sign, but I'm not volunteering... (and anyways, it is part of the bigger issue of general 
constant folding --- I suppose that Luke has a handle on that.)





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
   Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

__
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




--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319



__
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] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès



On 05/07/2014 02:55 PM, Simon Urbanek wrote:


On May 7, 2014, at 5:41 PM, Hervé Pagès hpa...@fhcrc.org wrote:


On 05/07/2014 02:01 PM, peter dalgaard wrote:


On 07 May 2014, at 21:52 , Simon Urbanek simon.urba...@r-project.org wrote:


On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant? Is there a way to express a negative 
constant in R? Hmm…



It's painful, but


bquote(.(-2)^2)

-2^2

eval(bquote(.(-2)^2))

[1] 4

bquote(.(-2)^2)[[2]]

[1] -2

mode(bquote(.(-2)^2)[[2]])

[1] numeric

The difficulty is that the tokenizer, which recognizes language elements before the parser goes to 
work on the grammatical structure, is unable to distinguish the -2 in -2 + 2 from the 
one in -2 ^ y.


Are you saying that the tokenizer could be made smarter and recognize
-2 as a token in -2 ^ y, just because you didn't put a space between
- and 2? So in -2 ^ y it would be token, but not in - 2^y.
An therefore precedence would now depend on whether there is a space
after the minus or not, or something like that? I'm confused.



Nope, precedence would not change at all. -2 and - 2 are two different things - in case you didn't 
realize that spaces are important, try a-2 vs a -2.


Yes, there is an precedent where space matters. I just hope you're not
saying you'd like to see that repeated for -2 vs - 2.


So, again, if -2 is a value then there is no precedence issue, since you have only operator in  
-2 ^ y namely ^.


If you make -2 a value, then yes you *effectively* change precedence
from a user point of view. You can be picky about terminology and argue
that it's not an operator precedence issue because there is no
operator involved but that doesn't change the fact that now it's a very
bad idea. I can't believe serious programmers are discussing ways to
make -2^2 return 4.

H.


In - 2 ^ y you have two operators, so precedence matters.

Cheers,
Simon




H.


And since constants are generated by the tokenizer, negative ones are not generated. I 
don't think it is completely out of reach for the parser to recognize the pattern 
unary minus a numeric constant and fold it into a constant of the opposite 
sign, but I'm not volunteering... (and anyways, it is part of the bigger issue of general 
constant folding --- I suppose that Luke has a handle on that.)





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
   Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

__
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




--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès

On 05/07/2014 02:45 PM, Simon Urbanek wrote:


On May 7, 2014, at 5:17 PM, Hervé Pagès hpa...@fhcrc.org wrote:


On 05/07/2014 12:52 PM, Simon Urbanek wrote:

On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant?


You wouldn't want -2 to be parsed as a single constant exactly for
the reason that you wouldn't want -2^2 to return 4. Having -2^2 treated
the same way as -x^2 is a sane feature.



On what grounds?


The last few centuries of mathematics. Some clever people have been
thinking about defining the rules for writing concise algebraic
expressions that do not leave room for interpretation/ambiguities.


-2 is one value - negative two - and if you square it, you get four - so that's 
not even a question of precedence. It's just a matter of interpretation: do you 
see the constant -2 or do you see the constant 2 with unary minus?


In -2^2, there is no question I see the latter. I'm a little biased
though, because, you know, I have some respect and admiration for the
tradition.

H.


When you print -2 you get -2 - and that's not a positive constant with an unary 
minus - or is it? ;) - aaah, will we ever know … R is good at hiding that 
subtlety from us:


a = quote(-2^2)
b = bquote(.(-2)^2)
a

-2^2

b

-2^2

eval(a)

[1] -4

eval(b)

[1] 4



Is there a way to express a negative constant in R? Hmm…


Maybe some people have some use cases for this (speed ?).


Wrong tree ;). You kick-started the trip but failed to follow the path it takes 
into the depths of the human mind … :P (or was that computer mind? ;))

Cheers,
Simon




Personally I don't. Of course it would require a special syntax,
something that would probably be as ugly and confusing as the
L suffix used for integer constants (L means long int in C).

H.





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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


Re: [Rd] precedence (was 'historical NA question')

2014-05-07 Thread Hervé Pagès



On 05/07/2014 02:45 PM, Simon Urbanek wrote:


On May 7, 2014, at 5:17 PM, Hervé Pagès hpa...@fhcrc.org wrote:


On 05/07/2014 12:52 PM, Simon Urbanek wrote:

On May 7, 2014, at 3:37 PM, Hervé Pagès hpa...@fhcrc.org wrote:


No big deal. These things can be tricky:

https://stat.ethz.ch/pipermail/r-devel/2006-January/036022.html

Sorry I couldn't resist ;-)



Yeah, but that's just yet another trip down the rabbit hole - why is -2 parsed 
as `-`(2) and not a single constant?


You wouldn't want -2 to be parsed as a single constant exactly for
the reason that you wouldn't want -2^2 to return 4. Having -2^2 treated
the same way as -x^2 is a sane feature.



On what grounds? -2 is one value - negative two - and if you square it, you get 
four - so that's not even a question of precedence. It's just a matter of 
interpretation: do you see the constant -2 or do you see the constant 2 with 
unary minus? When you print -2 you get -2 - and that's not a positive constant 
with an unary minus - or is it? ;) - aaah, will we ever know … R is good at 
hiding that subtlety from us:


a = quote(-2^2)
b = bquote(.(-2)^2)
a

-2^2

b

-2^2

eval(a)

[1] -4

eval(b)

[1] 4



Is there a way to express a negative constant in R? Hmm…


Maybe some people have some use cases for this (speed ?).


Wrong tree ;). You kick-started the trip but failed to follow the path it takes 
into the depths of the human mind … :P (or was that computer mind? ;))


BTW I don't see anything deep here, except maybe for the rabbit hole
you've put yourself in. Just sayin'...

H.



Cheers,
Simon




Personally I don't. Of course it would require a special syntax,
something that would probably be as ugly and confusing as the
L suffix used for integer constants (L means long int in C).

H.





On 05/07/2014 09:16 AM, John Chambers wrote:

On 5/7/14, 5:21 AM, Therneau, Terry M., Ph.D. wrote:

Hadley asked about the Blue book; my shelf still has the earlier brown
book
Becker and Chambers, 1984, S: An interactive environment for data
analysis and graphics.


Historically interesting, but there was never a guarantee that Version 3
of S (the blue book) was back-compatible with earlier versions.  We
gave users some help in getting on the road to converting, that was
all (see Appendix 4 to the blue book).

For that one brief moment, we felt free to innovate.

John



The manual page for precedence is

$   component select
%x  special operator
-   unary minus
:   sequence operator
^ **exponentiation
* / mult/div
+ - add/sub
  = = == != logical
!   not
 | and/or
- -   assignment

Terry Therneau

__
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


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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