Hi
One has to be careful when using fractions in seq step.
Although it works for 0.5> (seq(0,10, .5) - round(seq(0,10,.5),2))==0
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE
[16] TRUE TRUE TRUE TRUE TRUE TRUE
in case of 0.3 (or others) it does not always result in expected values (see
FAQ 7.31 for explanation)
> (seq(0,10, .3) - round(seq(0,10,.3),2))==0
[1] TRUE TRUE TRUE FALSE TRUE TRUE FALSE TRUE TRUE FALSE TRUE TRUE
[13] FALSE TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE FALSE
[25] FALSE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUE
TRUE>
Cheers
Petr
> -----Original Message-----
> From: R-help <r-help-bounces at r-project.org> On Behalf Of Erich
Subscriptions> Sent: Friday, October 29, 2021 9:17 AM
> To: Catherine Walt <walt at purpleemail.com>
> Cc: R mailing list <r-help at r-project.org>
> Subject: Re: [R] customize the step value
>
> seq(1.5,3.5,0.5)
>
> The docs for seq will show you many more options.
>
> > On 29.10.2021, at 09:06, Catherine Walt <walt at
purpleemail.com> wrote:
> >
> > dear members,
> >
> > Sorry I am newbie on R.
> > as we saw below:
> >
> >> 1.5:3.5
> > [1] 1.5 2.5 3.5
> >
> > How can I make the step to 0.5?
> > I want the result:
> >
> > 1.5 2.0 2.5 3.0 3.5
> >
> > Thanks.
> > Cathy
> >
> > ______________________________________________
> > R-help at r-project.org 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.
>
> ______________________________________________
> R-help at r-project.org 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.