This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Select and re-arrange rows of a sample

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


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


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.


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



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?