stats::row

Select and re-arrange rows of a sample

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

stats::row(s, r1, <r2, …>)
stats::row(s, r1 .. r2, <r3 .. r4, …>)

Description

stats::row(s, ..) creates a new sample from selected rows of the sample s.

stats::row is useful for selecting rows of interest or for re-arranging rows.

The rows of s specified by the remaining arguments of stats::row are used to build a new sample. The new sample contains the rows of s in the order specified by the call to stats::row. Rows can be duplicated by specifying the row index more than once.

Examples

Example 1

The following sample represents the "population" of a small town:

stats::sample([["1990", 10564], ["1991", 10956], 
               ["1992", 11007], ["1993", 11123], 
               ["1994", 11400], ["1995", 11645]])
"1990"  10564
"1991"  10956
"1992"  11007
"1993"  11123
"1994"  11400
"1995"  11645

We are only interested in the years 1990, 1991, 1992 and 1995. We create a new sample containing the rows of interest:

stats::row(%, 1..3, 6)
"1990"  10564
"1991"  10956
"1992"  11007
"1995"  11645

We reorder the sample:

stats::row(%, 4, 3, 2, 1)
"1995"  11645
"1992"  11007
"1991"  10956
"1990"  10564

Parameters

s

A sample of domain type stats::sample.

r1, r2, …

Positive integers representing row indices of the sample s. A range represents all rows from r1 through r2.

Return Values

Sample of domain type stats::sample.

Was this topic helpful?