[Rd] Add on argument in seq()

Millot Gael Gael.Millot at curie.fr
Tue Jun 16 12:36:37 CEST 2015


ok.

Many thanks for your help !

Best,

Gael.


De : Gabriel Becker [mailto:gmbecker at ucdavis.edu]
Envoyé : lundi 15 juin 2015 23:54
À : Hadley Wickham
Cc : Millot Gael; r-devel
Objet : Re: [Rd] Add on argument in seq()

Millot,

On Mon, Jun 15, 2015 at 9:19 AM, Hadley Wickham <h.wickham at gmail.com<mailto:h.wickham at gmail.com>> wrote:
Regardless of the value of the other arguments, the first element in
the output of seq() is _always_ `from`.

Indeed, as Hadley says, the output of seq must always start with from. It is a sequence starting at from and ending wherever the other arguments cause it to end. A sequence starting at from of length one is simply that single value. That is the contract I was referring to in my previous email. Apologies if that was not clear.
If that isn't the behavior you want when length.out  ends up being 1, your code will need to protect against that scenario.
I could see the argument for it being a warning/error if from and to are both specified and length.out is one, as a (lesser) part of the contract is that the last element of seq should be to, but even though it might make sense I really don't see that change going in. If I were you I'd just add an if statement in my function to check if length.out is 1 and move on.
Best,
~G


Hadley

On Mon, Jun 15, 2015 at 9:56 AM, Millot Gael <Gael.Millot at curie.fr<mailto:Gael.Millot at curie.fr>> wrote:
> Thanks for your answer.
>
> The rational behind my proposal is why taking "from" when length.out=1, more than "to" or "NA", or " integer(0) " ?
>
> This question seems basic. But is is not in certain situations, like when length.out =  unpredictable positive integer.
> And I haven't found in ?seq() the particular behavior of this function when length.out = 1.
>
> Thanks for your help !
>
> Best,
>
> Gael.
>
>
> De : Gabriel Becker [mailto:gmbecker at ucdavis.edu<mailto:gmbecker at ucdavis.edu>]
> Envoyé : lundi 15 juin 2015 16:25
> À : Millot Gael
> Cc : r-devel
> Objet : Re: [Rd] Add on argument in seq()
>
>
> Millot,
>
> I think the problem with that is that what you propose isn't a sequence starting  at from in any meaningful way, and thus does not satisfy the contract of the seq function.
>
> Best,
> ~G
> On Jun 15, 2015 7:12 AM, "Millot Gael" <Gael.Millot at curie.fr<mailto:Gael.Millot at curie.fr><mailto:Gael.Millot at curie.fr<mailto:Gael.Millot at curie.fr>>> wrote:
> Hi.
>
> I have a problem with the default behavior of seq(), which gives the argument "from" when the argument length.out = 1.
> This behavior is annoying when the number of value determine in length.out is not predictable.
> Would it be possible to add an argument that propose the median/mean, i.e. (from + to) / 2 when  length.out = 1 ? Examples:
>> seq(from = 1, to =  11, length.out=1) # current method gives "from"
> 1
>
>> seq(from = 1, to =  11, length.out=1) # alternative method gives the intermediate value of "from" and "to"
> 6
>
> Many thanks for your help.
>
> Best wishes,
>
> Gael Millot.
>
>
> Gael Millot
> UMR 3244 (IC-CNRS-UPMC) et Universite Pierre et Marie Curie
> Equipe Recombinaison et instabilite genetique
> Pav Trouillet Rossignol 5eme etage
> Institut Curie
> 26 rue d'Ulm
> 75248 Paris Cedex 05
> FRANCE
> tel : 33 1 56 24 66 34
> fax : 33 1 56 24 66 44
> Email : gael.millot at curie.fr<mailto:gael.millot at curie.fr><mailto:gael.millot at curie.fr<mailto:gael.millot at curie.fr>>
> http://perso.curie.fr/Gael.Millot/index.html
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org<mailto:R-devel at r-project.org><mailto:R-devel at r-project.org<mailto:R-devel at r-project.org>> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org<mailto:R-devel at r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


--
http://had.co.nz/



--
Gabriel Becker, PhD
Computational Biologist
Bioinformatics and Computational Biology
Genentech, Inc.

	[[alternative HTML version deleted]]



More information about the R-devel mailing list