R Sequences

Description

For certain R functions, such as when plotting statistical distributions, it is useful to produce a range of numbers with small increments for the sake of accuracy. To do this, we use the seq command. The command has three parameters: from, the inclusive lower bound of the sequence, to the inclusive upper bound of the sequence, and by, the increment of the sequnce. The following cell produces a sequence with the domain. The following cell produces a sequence from 2 to 6 with step 0.5.

Sage Cell

Code

seq(from=2, to=6, by=0.5)

Options

Setting length instead of increment

seq has a fourth, optional, parameter called length.out. This determines the amount of values in the sequence and will automatically calculate the increment (thus, the by parameter should not be set). The following cell generates a sequence from 2 to 6 with 11 values:

Code

seq(from=2, to=6, length.out=11)

Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

Attribute

Permalink:

Author:

Date: 23 Apr 2019 22:17

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License