function sample: diferences across R versions

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

function sample: diferences across R versions

JCFaria
Hi,
I just noticed the difference in a teaching data generation script between
version 3.6.1 and earlier.

#! R version 3.4.3
set.seed(2019); sample(1:10, 1)
[1] 8

#! R version 3.5.1patched
set.seed(2019); sample(1:10, 1)
[1] 8

#! R version 3.5.3patched
set.seed(2019); sample(1:10, 1)
[1] 8

#! R version 3.6.0patched
set.seed(2019); sample(1:10, 1)
[1] 8

#! R version 3.6.1patched
set.seed(2019); sample(1:10, 1)
[1] 9  # <--------------------------------- Here!

Is it a bug?
if not (is a new feature) how can I maintain compatibility between version
3.6.1 and all others?

Regards,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\

If you have software to deal with statistics, you have arms;
if you have good software, you have arms and legs;
if you have software like R, you have arms, legs and wings...
the height of your flight depends only on you!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: function sample: diferences across R versions

Patrick (Malone Quantitative)
My understanding is that sample() in 3.6.0 did, in fact, change in
ways that detach it from set.seed().

You can use RNGkind() or RNGversion() to recapture the old behavior.

See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in the
section CHANGES IN R 3.6.0 .

Also, please do not post in HTML.

Pat

On Tue, Jul 30, 2019 at 6:45 PM Jose Claudio Faria
<[hidden email]> wrote:

>
> Hi,
> I just noticed the difference in a teaching data generation script between
> version 3.6.1 and earlier.
>
> #! R version 3.4.3
> set.seed(2019); sample(1:10, 1)
> [1] 8
>
> #! R version 3.5.1patched
> set.seed(2019); sample(1:10, 1)
> [1] 8
>
> #! R version 3.5.3patched
> set.seed(2019); sample(1:10, 1)
> [1] 8
>
> #! R version 3.6.0patched
> set.seed(2019); sample(1:10, 1)
> [1] 8
>
> #! R version 3.6.1patched
> set.seed(2019); sample(1:10, 1)
> [1] 9  # <--------------------------------- Here!
>
> Is it a bug?
> if not (is a new feature) how can I maintain compatibility between version
> 3.6.1 and all others?
>
> Regards,
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> Jose Claudio Faria
> UESC/DCET/Brasil
> joseclaudio.faria at gmail.com
> Telefones:
> 55(73)3680.5545 - UESC
> 55(73)99966.9100 - VIVO
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>
> If you have software to deal with statistics, you have arms;
> if you have good software, you have arms and legs;
> if you have software like R, you have arms, legs and wings...
> the height of your flight depends only on you!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: function sample: diferences across R versions

Patrick (Malone Quantitative)
Poorly phrased--makes it act differently with respect to set.seed() .

On Tue, Jul 30, 2019 at 6:55 PM Patrick (Malone Quantitative)
<[hidden email]> wrote:

>
> My understanding is that sample() in 3.6.0 did, in fact, change in
> ways that detach it from set.seed().
>
> You can use RNGkind() or RNGversion() to recapture the old behavior.
>
> See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in the
> section CHANGES IN R 3.6.0 .
>
> Also, please do not post in HTML.
>
> Pat
>
> On Tue, Jul 30, 2019 at 6:45 PM Jose Claudio Faria
> <[hidden email]> wrote:
> >
> > Hi,
> > I just noticed the difference in a teaching data generation script between
> > version 3.6.1 and earlier.
> >
> > #! R version 3.4.3
> > set.seed(2019); sample(1:10, 1)
> > [1] 8
> >
> > #! R version 3.5.1patched
> > set.seed(2019); sample(1:10, 1)
> > [1] 8
> >
> > #! R version 3.5.3patched
> > set.seed(2019); sample(1:10, 1)
> > [1] 8
> >
> > #! R version 3.6.0patched
> > set.seed(2019); sample(1:10, 1)
> > [1] 8
> >
> > #! R version 3.6.1patched
> > set.seed(2019); sample(1:10, 1)
> > [1] 9  # <--------------------------------- Here!
> >
> > Is it a bug?
> > if not (is a new feature) how can I maintain compatibility between version
> > 3.6.1 and all others?
> >
> > Regards,
> > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> > Jose Claudio Faria
> > UESC/DCET/Brasil
> > joseclaudio.faria at gmail.com
> > Telefones:
> > 55(73)3680.5545 - UESC
> > 55(73)99966.9100 - VIVO
> > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> >
> > If you have software to deal with statistics, you have arms;
> > if you have good software, you have arms and legs;
> > if you have software like R, you have arms, legs and wings...
> > the height of your flight depends only on you!
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: function sample: diferences across R versions

JCFaria
Thanks Patrick.

I took a look at the documentation of the RNGkind and RNGversion
functions but didn't understand how they work. Can you exemplify how I
can, through them, to recapture the old behavior?

Best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\

If you have software to deal with statistics, you have arms;
if you have good software, you have arms and legs;
if you have software like R, you have arms, legs and wings...
the height of your flight depends only on you!

Em ter, 30 de jul de 2019 às 19:56, Patrick (Malone Quantitative)
<[hidden email]> escreveu:

>
> Poorly phrased--makes it act differently with respect to set.seed() .
>
> On Tue, Jul 30, 2019 at 6:55 PM Patrick (Malone Quantitative)
> <[hidden email]> wrote:
> >
> > My understanding is that sample() in 3.6.0 did, in fact, change in
> > ways that detach it from set.seed().
> >
> > You can use RNGkind() or RNGversion() to recapture the old behavior.
> >
> > See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in the
> > section CHANGES IN R 3.6.0 .
> >
> > Also, please do not post in HTML.
> >
> > Pat
> >
> > On Tue, Jul 30, 2019 at 6:45 PM Jose Claudio Faria
> > <[hidden email]> wrote:
> > >
> > > Hi,
> > > I just noticed the difference in a teaching data generation script between
> > > version 3.6.1 and earlier.
> > >
> > > #! R version 3.4.3
> > > set.seed(2019); sample(1:10, 1)
> > > [1] 8
> > >
> > > #! R version 3.5.1patched
> > > set.seed(2019); sample(1:10, 1)
> > > [1] 8
> > >
> > > #! R version 3.5.3patched
> > > set.seed(2019); sample(1:10, 1)
> > > [1] 8
> > >
> > > #! R version 3.6.0patched
> > > set.seed(2019); sample(1:10, 1)
> > > [1] 8
> > >
> > > #! R version 3.6.1patched
> > > set.seed(2019); sample(1:10, 1)
> > > [1] 9  # <--------------------------------- Here!
> > >
> > > Is it a bug?
> > > if not (is a new feature) how can I maintain compatibility between version
> > > 3.6.1 and all others?
> > >
> > > Regards,
> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> > > Jose Claudio Faria
> > > UESC/DCET/Brasil
> > > joseclaudio.faria at gmail.com
> > > Telefones:
> > > 55(73)3680.5545 - UESC
> > > 55(73)99966.9100 - VIVO
> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> > >
> > > If you have software to deal with statistics, you have arms;
> > > if you have good software, you have arms and legs;
> > > if you have software like R, you have arms, legs and wings...
> > > the height of your flight depends only on you!
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: function sample: diferences across R versions

Jeff Newmiller
There seem to be a couple of ways to do this.

Rngkind( sample.kind="Rounding" )

or

RNGversion("3.5.2")

per

?Random

https://stat.ethz.ch/pipermail/r-help/2019-June/463109.html

On July 30, 2019 5:31:13 PM PDT, Jose Claudio Faria <[hidden email]> wrote:

>Thanks Patrick.
>
>I took a look at the documentation of the RNGkind and RNGversion
>functions but didn't understand how they work. Can you exemplify how I
>can, through them, to recapture the old behavior?
>
>Best,
>///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>Jose Claudio Faria
>UESC/DCET/Brasil
>joseclaudio.faria at gmail.com
>Telefones:
>55(73)3680.5545 - UESC
>55(73)99966.9100 - VIVO
>///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>
>If you have software to deal with statistics, you have arms;
>if you have good software, you have arms and legs;
>if you have software like R, you have arms, legs and wings...
>the height of your flight depends only on you!
>
>Em ter, 30 de jul de 2019 às 19:56, Patrick (Malone Quantitative)
><[hidden email]> escreveu:
>>
>> Poorly phrased--makes it act differently with respect to set.seed() .
>>
>> On Tue, Jul 30, 2019 at 6:55 PM Patrick (Malone Quantitative)
>> <[hidden email]> wrote:
>> >
>> > My understanding is that sample() in 3.6.0 did, in fact, change in
>> > ways that detach it from set.seed().
>> >
>> > You can use RNGkind() or RNGversion() to recapture the old
>behavior.
>> >
>> > See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in
>the
>> > section CHANGES IN R 3.6.0 .
>> >
>> > Also, please do not post in HTML.
>> >
>> > Pat
>> >
>> > On Tue, Jul 30, 2019 at 6:45 PM Jose Claudio Faria
>> > <[hidden email]> wrote:
>> > >
>> > > Hi,
>> > > I just noticed the difference in a teaching data generation
>script between
>> > > version 3.6.1 and earlier.
>> > >
>> > > #! R version 3.4.3
>> > > set.seed(2019); sample(1:10, 1)
>> > > [1] 8
>> > >
>> > > #! R version 3.5.1patched
>> > > set.seed(2019); sample(1:10, 1)
>> > > [1] 8
>> > >
>> > > #! R version 3.5.3patched
>> > > set.seed(2019); sample(1:10, 1)
>> > > [1] 8
>> > >
>> > > #! R version 3.6.0patched
>> > > set.seed(2019); sample(1:10, 1)
>> > > [1] 8
>> > >
>> > > #! R version 3.6.1patched
>> > > set.seed(2019); sample(1:10, 1)
>> > > [1] 9  # <--------------------------------- Here!
>> > >
>> > > Is it a bug?
>> > > if not (is a new feature) how can I maintain compatibility
>between version
>> > > 3.6.1 and all others?
>> > >
>> > > Regards,
>> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>> > > Jose Claudio Faria
>> > > UESC/DCET/Brasil
>> > > joseclaudio.faria at gmail.com
>> > > Telefones:
>> > > 55(73)3680.5545 - UESC
>> > > 55(73)99966.9100 - VIVO
>> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>> > >
>> > > If you have software to deal with statistics, you have arms;
>> > > if you have good software, you have arms and legs;
>> > > if you have software like R, you have arms, legs and wings...
>> > > the height of your flight depends only on you!
>> > >
>> > >         [[alternative HTML version deleted]]
>> > >
>> > > ______________________________________________
>> > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> > > https://stat.ethz.ch/mailman/listinfo/r-help
>> > > PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> > > and provide commented, minimal, self-contained, reproducible
>code.
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: function sample: diferences across R versions

JCFaria
It works!
Thanks,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\

If you have software to deal with statistics, you have arms;
if you have good software, you have arms and legs;
if you have software like R, you have arms, legs and wings...
the height of your flight depends only on you!

Em ter, 30 de jul de 2019 às 22:00, Jeff Newmiller
<[hidden email]> escreveu:

>
> There seem to be a couple of ways to do this.
>
> Rngkind( sample.kind="Rounding" )
>
> or
>
> RNGversion("3.5.2")
>
> per
>
> ?Random
>
> https://stat.ethz.ch/pipermail/r-help/2019-June/463109.html
>
> On July 30, 2019 5:31:13 PM PDT, Jose Claudio Faria <[hidden email]> wrote:
> >Thanks Patrick.
> >
> >I took a look at the documentation of the RNGkind and RNGversion
> >functions but didn't understand how they work. Can you exemplify how I
> >can, through them, to recapture the old behavior?
> >
> >Best,
> >///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> >Jose Claudio Faria
> >UESC/DCET/Brasil
> >joseclaudio.faria at gmail.com
> >Telefones:
> >55(73)3680.5545 - UESC
> >55(73)99966.9100 - VIVO
> >///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> >
> >If you have software to deal with statistics, you have arms;
> >if you have good software, you have arms and legs;
> >if you have software like R, you have arms, legs and wings...
> >the height of your flight depends only on you!
> >
> >Em ter, 30 de jul de 2019 às 19:56, Patrick (Malone Quantitative)
> ><[hidden email]> escreveu:
> >>
> >> Poorly phrased--makes it act differently with respect to set.seed() .
> >>
> >> On Tue, Jul 30, 2019 at 6:55 PM Patrick (Malone Quantitative)
> >> <[hidden email]> wrote:
> >> >
> >> > My understanding is that sample() in 3.6.0 did, in fact, change in
> >> > ways that detach it from set.seed().
> >> >
> >> > You can use RNGkind() or RNGversion() to recapture the old
> >behavior.
> >> >
> >> > See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in
> >the
> >> > section CHANGES IN R 3.6.0 .
> >> >
> >> > Also, please do not post in HTML.
> >> >
> >> > Pat
> >> >
> >> > On Tue, Jul 30, 2019 at 6:45 PM Jose Claudio Faria
> >> > <[hidden email]> wrote:
> >> > >
> >> > > Hi,
> >> > > I just noticed the difference in a teaching data generation
> >script between
> >> > > version 3.6.1 and earlier.
> >> > >
> >> > > #! R version 3.4.3
> >> > > set.seed(2019); sample(1:10, 1)
> >> > > [1] 8
> >> > >
> >> > > #! R version 3.5.1patched
> >> > > set.seed(2019); sample(1:10, 1)
> >> > > [1] 8
> >> > >
> >> > > #! R version 3.5.3patched
> >> > > set.seed(2019); sample(1:10, 1)
> >> > > [1] 8
> >> > >
> >> > > #! R version 3.6.0patched
> >> > > set.seed(2019); sample(1:10, 1)
> >> > > [1] 8
> >> > >
> >> > > #! R version 3.6.1patched
> >> > > set.seed(2019); sample(1:10, 1)
> >> > > [1] 9  # <--------------------------------- Here!
> >> > >
> >> > > Is it a bug?
> >> > > if not (is a new feature) how can I maintain compatibility
> >between version
> >> > > 3.6.1 and all others?
> >> > >
> >> > > Regards,
> >> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> >> > > Jose Claudio Faria
> >> > > UESC/DCET/Brasil
> >> > > joseclaudio.faria at gmail.com
> >> > > Telefones:
> >> > > 55(73)3680.5545 - UESC
> >> > > 55(73)99966.9100 - VIVO
> >> > > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> >> > >
> >> > > If you have software to deal with statistics, you have arms;
> >> > > if you have good software, you have arms and legs;
> >> > > if you have software like R, you have arms, legs and wings...
> >> > > the height of your flight depends only on you!
> >> > >
> >> > >         [[alternative HTML version deleted]]
> >> > >
> >> > > ______________________________________________
> >> > > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >> > > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > > PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >> > > and provide commented, minimal, self-contained, reproducible
> >code.
> >
> >______________________________________________
> >[hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.