Om Sao
Om Sao

Reputation: 7663

R sequence generation without boundaries

> seq(0.15, 0.85, length.out = 4)
[1] 0.1500000 0.3833333 0.6166667 0.8500000

I get a sequence of 4 numbers which are equidistant and boundaries(0.15, 0.85) are also included

How I can generate a sequence with boundaries not included ?

I don't see any such method available in documentation: https://stat.ethz.ch/R-manual/R-devel/library/base/html/seq.html

Upvotes: 2

Views: 507

Answers (1)

boski
boski

Reputation: 2467

There is no parameter that controls this in base R. You can work around this issue by using the following code:

seq(0.15,0.85,length.out=4)[-c(1,4)]
[1] 0.3833333 0.6166667

In case length.out is given by a variable:

a = 4
seq(0.15,0.85,length.out=a)[-c(1,a)]
[1] 0.3833333 0.6166667

Upvotes: 2

Related Questions