[Bioc-devel] depends on packages providing classes

2014-10-28 Thread Kasper Daniel Hansen
What is the current best paradigm for using all the classes in
S4Vectors/GenomeInfoDb/GenomicRanges/IRanges

I obviously import methods and classes from the relevant packages.

But shouldn't I depend on these packages as well?  Since I basically want
the user to have this functionality at the command line? That is what I do
now.

That of course leads to the R CMD check NOTE on depending on too many
packages I guess I should ignore that one.

Best,
Kasper

[[alternative HTML version deleted]]

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


Re: [Bioc-devel] depends on packages providing classes

2014-10-28 Thread Hervé Pagès

Hi,

On 10/28/2014 08:48 AM, Vincent Carey wrote:

On Tue, Oct 28, 2014 at 11:23 AM, Kasper Daniel Hansen 
kasperdanielhan...@gmail.com wrote:


Well, first I want to make sure that there is not something special
regarding S4 methods and classes. I have a feeling that they are a special
case.

Second, while I agree with Jim's general opinion, it is a little bit
different when I have return objects which are defined in other packages.
If I don't depend on this other package, the user is hosed wrt. the return
object, unless I manually export all classes from this other



In what sense?  If you return an instance of GRanges, certain things can be
done
even if GenomicRanges is not attached.


Yes certain things maybe, but it's hard to predict which ones.


 You can get values of slots, for
example.

With the following little package

%vjcair cat foo/NAMESPACE

importFrom(IRanges, IRanges)

importClassesFrom(GenomicRanges, GRanges)

importFrom(GenomicRanges, GRanges)

export(myfun)



%vjcair cat foo/DESCRIPTION

Package: foo

Title: foo

Version: 0.0.0

Author: VJ Carey st...@channing.harvard.edu

Description:

Suggests:

Depends:

Imports: GenomicRanges

Maintainer: VJ Carey st...@channing.harvard.edu

License: Private

LazyLoad: yes



%vjcair cat foo/R/*

myfun = function(seqnames=1, ranges=IRanges(1,2), ...)

GRanges(seqnames=seqnames, ranges=ranges, ...)


The following works:



library(foo)



x = myfun()



x


GRanges object with 1 range and 0 metadata columns:

   seqnamesranges strand

  Rle IRanges  Rle

   [1]1[1, 2]  *

   ---

   seqinfo: 1 sequence from an unspecified genome; no seqlengths


So the show method works, even though I have not touched it.  (I did not

expect it to work, in fact.)


Exactly. Let's call it luck ;-)


 Additionally, I can get access to slots.


The end user should never try to access slots directly but use getters
and setters instead. And most getters and setters for GRanges objects
are defined and documented in the GenomicRanges package. Those that are
not are defined in packages that GenomicRanges depends on.


 But
ranges()

fails.  If I, the user, want to use it, I need to arrange for that.


IMO if your package returns a GRanges object to the user, then the user
should be able to access the man page for GRanges objects with ?GRanges.
And that works only if the GenomicRanges package is attached. Attaching
GenomicRanges will also attach other packages that GenomicRanges depends
on where some GRanges accessors might be defined and documented (e.g.
metadata()).




In some cases you'll decide you want the user to have a full complement of

methods for your package to function meaningfully.  For example, I am
considering

using dplyr idioms to work with data structures in a package, and it seems
I should

just depend on dplyr rather than pick out and document which things I want
to expose.  But that

may still be an undesirable design.



package, like
   importClassesFrom(GenomicRanges, GRanges)
   exportClasses(GRanges)
Surely that is not intended.

It is important that my package works without being attached to the search
path and I do this by carefully importing what I need, ie. my code does not
require that my dependencies are attached to the search path.  But the end
user will be hosed without it.


Yes s/he will. Fortunately when your package namespace gets loaded by
another package, then nothing gets attached to the search path, even if
your package depends (instead of imports) on other packages. So using
Depends instead of Imports for your own dependencies won't make any
difference in that respect, which is good.



My impression is that the NOTE in R CMD check was written by someone who
did not anticipate large-scale use and re-use of classes and methods across
many packages.


That's my impression too.

Cheers,
H.



Best,
Kasper


On Tue, Oct 28, 2014 at 11:14 AM, James W. MacDonald jmac...@uw.edu
wrote:


I agree with Vince. It's your job as a package developer to make
available to your package all the functions necessary for the package to
work. But I am not sure it is your job to load all the packages that your
end user might need.

Best,

Jim



On Tue, Oct 28, 2014 at 11:04 AM, Vincent Carey 
st...@channing.harvard.edu wrote:


On Tue, Oct 28, 2014 at 10:19 AM, Kasper Daniel Hansen 
kasperdanielhan...@gmail.com wrote:


What is the current best paradigm for using all the classes in
S4Vectors/GenomeInfoDb/GenomicRanges/IRanges

I obviously import methods and classes from the relevant packages.

But shouldn't I depend on these packages as well?  Since I basically

want

the user to have this functionality at the command line? That is what

I do

now.



I've wondered about this as well.  It seems the principle is that the
user
should
take care of attaching additional packages when needed.  It might be
appropriate
to give a hint in the package startup message, if having some other
package
attached
would 

Re: [Bioc-devel] depends on packages providing classes

2014-10-28 Thread Vincent Carey
On Tue, Oct 28, 2014 at 2:29 PM, Hervé Pagès hpa...@fredhutch.org wrote:

 Hi,

 On 10/28/2014 08:48 AM, Vincent Carey wrote:

 On Tue, Oct 28, 2014 at 11:23 AM, Kasper Daniel Hansen 
 kasperdanielhan...@gmail.com wrote:

  Well, first I want to make sure that there is not something special
 regarding S4 methods and classes. I have a feeling that they are a
 special
 case.

 Second, while I agree with Jim's general opinion, it is a little bit
 different when I have return objects which are defined in other packages.
 If I don't depend on this other package, the user is hosed wrt. the
 return
 object, unless I manually export all classes from this other


 In what sense?  If you return an instance of GRanges, certain things can
 be
 done
 even if GenomicRanges is not attached.


 Yes certain things maybe, but it's hard to predict which ones.

   You can get values of slots, for
 example.

 With the following little package

 %vjcair cat foo/NAMESPACE

 importFrom(IRanges, IRanges)

 importClassesFrom(GenomicRanges, GRanges)

 importFrom(GenomicRanges, GRanges)

 export(myfun)



 %vjcair cat foo/DESCRIPTION

 Package: foo

 Title: foo

 Version: 0.0.0

 Author: VJ Carey st...@channing.harvard.edu

 Description:

 Suggests:

 Depends:

 Imports: GenomicRanges

 Maintainer: VJ Carey st...@channing.harvard.edu

 License: Private

 LazyLoad: yes



 %vjcair cat foo/R/*

 myfun = function(seqnames=1, ranges=IRanges(1,2), ...)

 GRanges(seqnames=seqnames, ranges=ranges, ...)


 The following works:


  library(foo)


  x = myfun()


  x


 GRanges object with 1 range and 0 metadata columns:

seqnamesranges strand

   Rle IRanges  Rle

[1]1[1, 2]  *

---

seqinfo: 1 sequence from an unspecified genome; no seqlengths


 So the show method works, even though I have not touched it.  (I did not

 expect it to work, in fact.)


 Exactly. Let's call it luck ;-)

   Additionally, I can get access to slots.


 The end user should never try to access slots directly but use getters
 and setters instead. And most getters and setters for GRanges objects
 are defined and documented in the GenomicRanges package. Those that are
 not are defined in packages that GenomicRanges depends on.

   But
 ranges()

 fails.  If I, the user, want to use it, I need to arrange for that.


 IMO if your package returns a GRanges object to the user, then the user
 should be able to access the man page for GRanges objects with ?GRanges.


Oddly enough, that seems to be incorrect.  I added a man page to foo that
has
a \link[GenomicRanges]{GRanges-class}.  I ran help.start and the cross
reference
from my man page succeeds.  Furthermore with the sessionInfo below, ?GRanges
succeeds at the CLI.  I am not trying to defend the NOTE but the principle
of minimizing
Depends declarations needs to be considered critically, and I am just
exploring the space.

 ?GRanges  # it worked as usual in the tty

 sessionInfo()

R version 3.1.1 (2014-07-10)

Platform: x86_64-apple-darwin13.1.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] stats graphics  grDevices datasets  utils tools methods

[8] base


other attached packages:

[1] foo_0.0.0rmarkdown_0.3.8  knitr_1.6

[4] weaver_1.31.0codetools_0.2-9  digest_0.6.4

[7] BiocInstaller_1.16.0


loaded via a namespace (and not attached):

 [1] BiocGenerics_0.11.5   evaluate_0.5.5formatR_1.0

 [4] GenomeInfoDb_1.1.26   GenomicRanges_1.17.48 htmltools_0.2.6

 [7] IRanges_1.99.32   parallel_3.1.1S4Vectors_0.2.8

[10] stats4_3.1.1  stringr_0.6.2 XVector_0.5.8


 And that works only if the GenomicRanges package is attached. Attaching
 GenomicRanges will also attach other packages that GenomicRanges depends
 on where some GRanges accessors might be defined and documented (e.g.
 metadata()).



 In some cases you'll decide you want the user to have a full complement of

 methods for your package to function meaningfully.  For example, I am
 considering

 using dplyr idioms to work with data structures in a package, and it seems
 I should

 just depend on dplyr rather than pick out and document which things I want
 to expose.  But that

 may still be an undesirable design.


  package, like
importClassesFrom(GenomicRanges, GRanges)
exportClasses(GRanges)
 Surely that is not intended.

 It is important that my package works without being attached to the
 search
 path and I do this by carefully importing what I need, ie. my code does
 not
 require that my dependencies are attached to the search path.  But the
 end
 user will be hosed without it.


 Yes s/he will. Fortunately when your package namespace gets loaded by
 another package, then nothing gets attached to the search path, even if
 your package depends (instead of imports) on other packages. So using
 Depends instead of Imports for your own dependencies won't make 

Re: [Bioc-devel] depends on packages providing classes

2014-10-28 Thread Hervé Pagès



On 10/28/2014 12:42 PM, Vincent Carey wrote:



On Tue, Oct 28, 2014 at 2:29 PM, Hervé Pagès hpa...@fredhutch.org
mailto:hpa...@fredhutch.org wrote:

Hi,

On 10/28/2014 08:48 AM, Vincent Carey wrote:

On Tue, Oct 28, 2014 at 11:23 AM, Kasper Daniel Hansen 
kasperdanielhan...@gmail.com
mailto:kasperdanielhan...@gmail.com wrote:

Well, first I want to make sure that there is not something
special
regarding S4 methods and classes. I have a feeling that they
are a special
case.

Second, while I agree with Jim's general opinion, it is a
little bit
different when I have return objects which are defined in
other packages.
If I don't depend on this other package, the user is hosed
wrt. the return
object, unless I manually export all classes from this other


In what sense?  If you return an instance of GRanges, certain
things can be
done
even if GenomicRanges is not attached.


Yes certain things maybe, but it's hard to predict which ones.

  You can get values of slots, for
example.

With the following little package

%vjcair cat foo/NAMESPACE

importFrom(IRanges, IRanges)

importClassesFrom(__GenomicRanges, GRanges)

importFrom(GenomicRanges, GRanges)

export(myfun)



%vjcair cat foo/DESCRIPTION

Package: foo

Title: foo

Version: 0.0.0

Author: VJ Carey st...@channing.harvard.edu
mailto:st...@channing.harvard.edu

Description:

Suggests:

Depends:

Imports: GenomicRanges

Maintainer: VJ Carey st...@channing.harvard.edu
mailto:st...@channing.harvard.edu

License: Private

LazyLoad: yes



%vjcair cat foo/R/*

myfun = function(seqnames=1, ranges=IRanges(1,2), ...)

 GRanges(seqnames=seqnames, ranges=ranges, ...)


The following works:


library(foo)


x = myfun()


x


GRanges object with 1 range and 0 metadata columns:

seqnamesranges strand

   Rle IRanges  Rle

[1]1[1, 2]  *

---

seqinfo: 1 sequence from an unspecified genome; no seqlengths


So the show method works, even though I have not touched it.  (I
did not

expect it to work, in fact.)


Exactly. Let's call it luck ;-)

  Additionally, I can get access to slots.


The end user should never try to access slots directly but use getters
and setters instead. And most getters and setters for GRanges objects
are defined and documented in the GenomicRanges package. Those that are
not are defined in packages that GenomicRanges depends on.

  But
ranges()

fails.  If I, the user, want to use it, I need to arrange for that.


IMO if your package returns a GRanges object to the user, then the user
should be able to access the man page for GRanges objects with ?GRanges.


Oddly enough, that seems to be incorrect.  I added a man page to foo
that has
a \link[GenomicRanges]{GRanges-class}.  I ran help.start and the cross
reference
from my man page succeeds.  Furthermore with the sessionInfo below, ?GRanges
succeeds at the CLI.


Did you try to run example(GRanges)? I'm not sure that will work.

For example after I do library(rtracklayer), I can indeed do
?DNAStringSet at the command line (I'm surprised this works), but
then example(DNAStringSet) fails:

   example(DNAStringSet)
  Warning message:
  In example(DNAStringSet) : no help found for ‘DNAStringSet’

I'm also surprised this is just a warning but that's another story...

H.


 I am not trying to defend the NOTE but the
principle of minimizing
Depends declarations needs to be considered critically, and I am just
exploring the space.

  ?GRanges  # it worked as usual in the tty

  sessionInfo()

R version 3.1.1 (2014-07-10)

Platform: x86_64-apple-darwin13.1.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] stats graphics  grDevices datasets  utils tools methods

[8] base


other attached packages:

[1] foo_0.0.0rmarkdown_0.3.8  knitr_1.6

[4] weaver_1.31.0codetools_0.2-9  digest_0.6.4

[7] BiocInstaller_1.16.0


loaded via a namespace (and not attached):

  [1] BiocGenerics_0.11.5   evaluate_0.5.5formatR_1.0

  [4] GenomeInfoDb_1.1.26   GenomicRanges_1.17.48 htmltools_0.2.6

  [7] IRanges_1.99.32   parallel_3.1.1S4Vectors_0.2.8

[10] stats4_3.1.1  stringr_0.6.2 XVector_0.5.8

And that works only if the GenomicRanges package is attached. Attaching
GenomicRanges will also attach other packages that GenomicRanges depends

[Rd] RFC: is.whole() ? {how to judge if a variable is an integer}

2014-10-28 Thread Martin Maechler
Diverted to R-devel, as I'm requesting comments about a proposal
to add is.whole() to R just so this issue does not trail on for
centuries (;-), see below.

 William Dunlap wdun...@tibco.com
 on Sat, 18 Oct 2014 10:33:05 -0700 writes:

 3. all.equal(a, as.integer(a))
 Note that this one tests if 'a' can be stored accurately as a 32-bit 
signed
 integer.  If you want to know if 'a' can be used as an accurate count, 
then
 you want to test if a+1a (use abs() in case a is negative).  E.g., try 
this
 for a-2^49-1, about 5*10^14.

 You have to decide what properties of integers you are interested in.

 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

good point, thank you, Bill.

This whole issue comes up about once year (at least), it seems to me,
and every time there are some good and some not so good propositions,
some aiming for vectorized / whole object solutions some, only
assuming scalar input.

Indeed, I'd claim that all three proposals cited below are not
good enough in one way or the other though one
could argue that a tolerance = 0 version would be good enough,
and hence the
  function(x) x %% 1  == 0
would be sufficient. 

In the CRAN package 'sfsmisc' (which I maintain), Alain Hauser 
recently added an

 is.whole()

function which works vectorized and uses a 'tolerance' and
then all.equal(), but in better way than (most / all ?) what was proposed in
this thread (line 486 ff of 
 https://github.com/mmaechler/sfsmisc/blob/master/R/misc-goodies.R ).

Further, the CRAN packages
 'gmp'   (infinite precision integer and rational arithmetic) and
 'Rmpfr' ('infinite' precision floating point arithmetic) contain
an S3 generic  is.whole() function and methods for their own
number classes and a default method (( which however assumes
a tolerance of zero, the same as the  x %% 1 == 0 proposal)).

Given all this, the r-help and stackoverflow threads,
maybe we should decide that such an is.whole() function should
be added to R and maintained (by me for the time), so we do have
a better place to point people to, and well documented -- and
eventually optimized -- behavior ?

Personally I do think I'd want a signature of
function (x, tolerance = sqrt(.Machine$double.eps))


Martin


 On Sat, Oct 18, 2014 at 10:02 AM, PO SU rhelpmaill...@163.com wrote:
 
 Tks for your help, after investigate in your link, i find there seems 
three ways can be adoped:
 1.is.wholenumber - function(x, tol = .Machine$double.eps^0.5)  
abs(x - round(x))  tol)
 e.g. is.wholenumber(1)
 2.   x%%1==0
 
 
 3. all.equal(a, as.integer(a))
 
 
 and also included your last suggestion using floor. and also tks for 
other helpers!
 --
 
 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU
 
 At 2014-10-18 22:48:15, Sergio Fonda sergio.fond...@gmail.com wrote:
 
 Sorry for my previous hurry misunderstanding.
 Try this link:
 
http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer
 
 2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:
 
 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. 
but deeply, when i want to know 1 is an integer,  there seems no easy way to 
get the answer.
 
 So, is there anyone happen to know it?
 

 
 At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
 
 But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
 
 If you do floating point arithmetic on integers you'll usually get 
floating point answers, including the 5.0.
 
 
 
 See FAQ 7.31 for the usual floating point problem, and ?all.equal for 
the usual answer to it. You could see if a result is close to an integer by,for 
example, using all.equal to compare it to itself after rounding.
 
 
 
 S

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


Re: [Rd] RFC: is.whole() ? {how to judge if a variable is an integer}

2014-10-28 Thread Duncan Murdoch
On 28/10/2014, 5:32 AM, Martin Maechler wrote:
 Diverted to R-devel, as I'm requesting comments about a proposal
 to add is.whole() to R just so this issue does not trail on for
 centuries (;-), see below.
 

I didn't read the thread in question, but I think Bill's comment is
crucial:  what properties of integers are you interested in testing?

One that comes up a lot is that some non-integral values print as
integers, and people get confused when using them as indices.  For
example, this prints results that surprise some people:

x - 1:10
index - 4 - 1.e-10
index
x[index]

I would think is.whole(index) should return FALSE here, but the sfsmisc
function defaults to a nonzero tolerance, and returns TRUE.

Duncan Murdoch

 William Dunlap wdun...@tibco.com
 on Sat, 18 Oct 2014 10:33:05 -0700 writes:
 
  3. all.equal(a, as.integer(a))
  Note that this one tests if 'a' can be stored accurately as a 32-bit 
 signed
  integer.  If you want to know if 'a' can be used as an accurate count, 
 then
  you want to test if a+1a (use abs() in case a is negative).  E.g., try 
 this
  for a-2^49-1, about 5*10^14.
 
  You have to decide what properties of integers you are interested in.
 
  Bill Dunlap
  TIBCO Software
  wdunlap tibco.com
 
 good point, thank you, Bill.
 
 This whole issue comes up about once year (at least), it seems to me,
 and every time there are some good and some not so good propositions,
 some aiming for vectorized / whole object solutions some, only
 assuming scalar input.
 
 Indeed, I'd claim that all three proposals cited below are not
 good enough in one way or the other though one
 could argue that a tolerance = 0 version would be good enough,
 and hence the
 function(x) x %% 1  == 0
 would be sufficient. 
 
 In the CRAN package 'sfsmisc' (which I maintain), Alain Hauser 
 recently added an
 
is.whole()
 
 function which works vectorized and uses a 'tolerance' and
 then all.equal(), but in better way than (most / all ?) what was proposed in
 this thread (line 486 ff of 
  https://github.com/mmaechler/sfsmisc/blob/master/R/misc-goodies.R ).
 
 Further, the CRAN packages
  'gmp'   (infinite precision integer and rational arithmetic) and
  'Rmpfr' ('infinite' precision floating point arithmetic) contain
 an S3 generic  is.whole() function and methods for their own
 number classes and a default method (( which however assumes
 a tolerance of zero, the same as the  x %% 1 == 0 proposal)).
 
 Given all this, the r-help and stackoverflow threads,
 maybe we should decide that such an is.whole() function should
 be added to R and maintained (by me for the time), so we do have
 a better place to point people to, and well documented -- and
 eventually optimized -- behavior ?
 
 Personally I do think I'd want a signature of
 function (x, tolerance = sqrt(.Machine$double.eps))
 
 
 Martin
 
 
  On Sat, Oct 18, 2014 at 10:02 AM, PO SU rhelpmaill...@163.com wrote:
  
  Tks for your help, after investigate in your link, i find there seems 
 three ways can be adoped:
  1.is.wholenumber - function(x, tol = .Machine$double.eps^0.5)  
 abs(x - round(x))  tol)
  e.g. is.wholenumber(1)
  2.   x%%1==0
  
  
  3. all.equal(a, as.integer(a))
  
  
  and also included your last suggestion using floor. and also tks for 
 other helpers!
  --
  
  PO SU
  mail: desolato...@163.com
  Majored in Statistics from SJTU
  
  At 2014-10-18 22:48:15, Sergio Fonda sergio.fond...@gmail.com 
 wrote:
  
  Sorry for my previous hurry misunderstanding.
  Try this link:
  
 http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer
  
  2014-10-18 16:25 GMT+02:00 PO SU rhelpmaill...@163.com:
  
  It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. 
 but deeply, when i want to know 1 is an integer,  there seems no easy way to 
 get the answer.
  
  So, is there anyone happen to know it?
  
 
  
  At 2014-10-18 20:10:09, S Ellison s.elli...@lgcgroup.com wrote:
  
  But i use a-10/b ,  b is some value ,may be  5, maybe 5.5
  
  If you do floating point arithmetic on integers you'll usually get 
 floating point answers, including the 5.0.
  
  
  
  See FAQ 7.31 for the usual floating point problem, and ?all.equal for 
 the usual answer to it. You could see if a result is close to an integer 
 by,for example, using all.equal to compare it to itself after rounding.
  
  
  
  S
 
 __
 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] is.whole()

2014-10-28 Thread Therneau, Terry M., Ph.D.

Martin,
  I can't imagine using such a function myself, the reason being that as Bill and Duncan 
point out, the correct answer depends on the situation.
  But given the regular reappearance of this topic, I think that perhaps creation of your 
function is a good idea, largely to function as a repository for the knowlege.  If one 
takes that view, then perhas the function has two optional arguments: case and 
tolerance.  The first would choose a scenario of exact, numeric, count, etc, where 
exact refers to Duncan's case, numeric to your default, and count to Bill's  a+1  a.  The 
second argument would be rarely used.
   The primary point of the function would be the Details section of its manual page. 
Whenver the issue comes up the response could then be see the is.whole() function and its 
documentation.


Terry T.

On 10/28/2014 06:00 AM, r-devel-requ...@r-project.org wrote:

Diverted to R-devel, as I'm requesting comments about a proposal
to add is.whole() to R just so this issue does not trail on for
centuries (;-), see below.





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


Re: [Rd] is.whole()

2014-10-28 Thread Greg Snow
Just to anticipate future discussion from math purists (and hopefully
not to throw too much of a wrench in the works), what would be the
return of:

is.whole(-1)

or

is.whole(-1L)

?

I can see arguments for both TRUE and FALSE from both the math purity
group and the what will happen when I try to use this for
subsetting? group.

On Tue, Oct 28, 2014 at 9:14 AM, Martin Maechler
maech...@stat.math.ethz.ch wrote:
 Therneau, Terry M , Ph D thern...@mayo.edu
 on Tue, 28 Oct 2014 07:44:20 -0500 writes:

  Martin,
  I can't imagine using such a function myself, the reason being that as 
 Bill and Duncan
  point out, the correct answer depends on the situation.

 yes, of course.
 OTOH, if the function is used for argument checking inside
 another function, using such an  is.whole(.)  may come as a
 handy, and well readable {because self explaining} expression.

  But given the regular reappearance of this topic, I think that perhaps 
 creation of your
  function is a good idea, largely to function as a repository for the 
 knowlege.  If one
  takes that view, then perhas the function has two optional arguments: 
 case and
  tolerance.  The first would choose a scenario of exact, numeric, 
 count, etc, where
  exact refers to Duncan's case, numeric to your default, and count to 
 Bill's  a+1  a.  The
  second argument would be rarely used.

  The primary point of the function would be the Details section of its 
 manual page.
  Whenver the issue comes up the response could then be see the 
 is.whole() function and its
  documentation.

  Terry T.

 Thank you, Duncan, and Terry,

 Yes, indeed, a primary point of the function would just be that:
 A coherent place to point to (and \link{.} to e.g. from the
 as.integer help page).

 Apropos optional arguments and their defaults: It may indeed be
 a better (than sfsmisc::is.whole 's default) idea to use a
 default tolerence = 0 rather than  sqrt(.Machine$double.eps). ..
 and I think the argument / principle of thinking of what happens
 when integer - indexing with such numbers is also aa good one.
 That one has the drawback of asymmetry, i.e., of treating
 4 + 1e-10 very differently than
 4 - 1e-10

 Martin



  On 10/28/2014 06:00 AM, r-devel-requ...@r-project.org wrote:
  Diverted to R-devel, as I'm requesting comments about a proposal
  to add is.whole() to R just so this issue does not trail on for
  centuries (;-), see below.
 

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



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


Re: [Rd] OSX Yosemite (10.10): Are package binaries the same as for OSX Mavericks (10.9)?

2014-10-28 Thread Henrik Bengtsson
On Mon, Oct 27, 2014 at 12:33 PM, Dan Tenenbaum dtene...@fredhutch.org wrote:


 - Original Message -
 From: Henrik Bengtsson h...@biostat.ucsf.edu
 To: Dan Tenenbaum dtene...@fredhutch.org
 Cc: R-devel r-devel@r-project.org
 Sent: Monday, October 27, 2014 12:21:49 PM
 Subject: Re: [Rd] OSX Yosemite (10.10): Are package binaries the same as for 
 OSX Mavericks (10.9)?

 On Mon, Oct 27, 2014 at 11:23 AM, Dan Tenenbaum
 dtene...@fredhutch.org wrote:
 
 
  - Original Message -
  From: Dan Tenenbaum dtene...@fredhutch.org
  To: Henrik Bengtsson h...@biostat.ucsf.edu
  Cc: R-devel r-devel@r-project.org
  Sent: Monday, October 27, 2014 11:21:59 AM
  Subject: Re: [Rd] OSX Yosemite (10.10): Are package binaries the
  same as for OSX Mavericks (10.9)?
 
 
 
  - Original Message -
   From: Henrik Bengtsson h...@biostat.ucsf.edu
   To: R-devel r-devel@r-project.org
   Sent: Monday, October 27, 2014 11:16:10 AM
   Subject: [Rd] OSX Yosemite (10.10): Are package binaries the
   same
   as for OSX Mavericks (10.9)?
  
   I'm trying to help someone to troubleshoot possible OSX Yosemite
   issues, but I've only got access to OSX ( 10.9) so I cannot
   check
   myself.
  
   When building/installing binary R packages, there are different
   binaries depending on OSX version.  For instance, CRAN provides
   different binaries for 'OS X Snow Leopard' and 'OS X Mavericks',
   e.g.
   http://cran.r-project.org/web/packages/matrixStats/index.html.
  
   What about the new OSX Yosemite?  From
   http://cran.r-project.org/doc/manuals/r-devel/R-admin.html#Yosemite
   it
   looks like its binaries are the same/compatible with those of
   'OS X
   Mavericks' - can someone please confirm this?  Another way to
   put
   it,
   if a repository provides OSX Mavericks binaries will an OSX
   Yosemite
   user install these or we s/he fall back to installing from
   source?
  
 
  Yes, a Yosemite user will by default be installing packages built
  on
  Mavericks using the Mavericks build of R, and they should work.
 
 
  Provided of course that that Yosemite user is using the Mavericks
  build of R. They could also be using the Snow Leopard build of R
  which should also work, and would be installing by default
  packages build on Snow Leopard using the Snow Leopard build of R.

 Thanks for this Dan.

 As far as I understand, for an OSX user to install binary packages
 option 'pkgType' has to be set to either mac.binary or
 mac.binary.mavericks.  A few questions for clarification:

 Q. Is it the default that 'pkgType' be set to mac.binary on OSX (
 10.9) and to mac.binary.mavericks on OSX (= 10.9)?


 Q. Are you saying that if an OSX (= 10.9) user uses
 options(pkgType=mac.binary), then install.packages() will install
 the OSX 10.6 (Snow Leopard) binaries *and* that these binaries are
 backward compatible and should work equally well?

 Q. In other words, if a user have problems with a particular OSX 10.9
 (Mavericks) binary, would a first step of troubleshooting be to ask
 that user to try the OSX 10.6 (Snow Leopard) build?

 Q. If a user has options(pkgType=mac.binary.mavericks), but the
 repository does not provide such binaries, will install.packages()
 fall back to mac.binary, or will it go directly to source?



 First of all, this should be on R-SIG-Mac.

I considered that, but I'm also asking this as a package developer and
wonder what happens if someone installs my packages incorrectly and I
need to troubleshoot what's reported as a bugs but may not be, so I
though it would be more appropriate here.


 It all depends on what build of R you are using. You can be on Snow Leopard 
 or later (including Mavericks and Yosemite)  and use the Snow Leopard build. 
 The default package type will be mac.binary.

 You can be on Mavericks or later and using the Mavericks build of R and your 
 package type will by default be mac.binary.mavericks.

Just for the record: I've verified that it is not possible to install
the Mavericks build of R on a pre-Mavericks OSX version by mistake; on
an OSX 10.6.8 machine I get:

$ wget 
http://r.research.att.com/mavericks/R-3.1-branch/R-3.1-branch-mavericks.pkg
$ sudo installer -pkg R-3.1-branch-mavericks.pkg -target /
...
installer: This build of R requires Mac OS X 10.9 or higher.
$


 The two types of binary packages are NOT binary compatible! You should not 
 mix and match them. (Technically, if a given package does not have native 
 code in it, it should work, but you don't really want to go there.)

I understand that packages without native code should work, but is
there a reason for why R and install.packages() allows such mix and
matching in the first place?  I've tested
install.packages(matrixStats, type=mac.binary.mavericks) on an OSX
10.6.8 machine and it install the package without complaints.
Wouldn't it be better then if it gave an error:

 install.packages(matrixStats, type=mac.binary.mavericks)
Installing package into '/Users/hb/Library/R/3.1/library'
(as 'lib' is