Learn R Programming

vws (version 0.3.0)

seq_knots: Produce a sequence of knots

Description

Produce knots which define \(N\) equally-spaced intervals between (finite) endpoints lo and hi.

Usage

seq_knots(lo, hi, N, endpoints = FALSE)

Value

A vector that represents a sequence of knots. If endpoints = TRUE, it contains \(N+1\) evenly-spaced knots that represent \(N\) regions with endpoints included. If endpoints = FALSE, the endpoints are excluded.

Arguments

lo

Left endpoint; must be finite.

hi

Right endpoint; must be finite.

N

Number of desired intervals.

endpoints

logical; if TRUE, include the endpoints.

Examples

Run this code
seq_knots(0, 1, N = 5)
seq_knots(0, 1, N = 5, endpoints = TRUE)

# Trivial case: make endpoints for just one interval
seq_knots(0, 1, N = 1)
seq_knots(0, 1, N = 1, endpoints = TRUE)

# The following calls throw errors
tryCatch({
  seq_knots(0, 1, N = 0)
}, error = function(e) { print(e) })
tryCatch({
  seq_knots(0, Inf, N = 5)
}, error = function(e) { print(e) })
tryCatch({
  seq_knots(-Inf, 1, N = 5)
}, error = function(e) { print(e) })

Run the code above in your browser using DataLab