arrange: Order matrix elements based on rownames and/or colnames

Description Usage Arguments Details Value Examples

View source: R/manip.R

Description

This is a convenience function for ordering rows and columns within a matrix.

Usage

1
arrange(m, order.rows = TRUE, order.cols = TRUE, comparator = NULL)

Arguments

m

A matrix whose rows and/or columns are to be arranged

order.rows

Whether rows are to be ordered. Defaults to TRUE

order.cols

Whether columns are to be ordered. Defaults to TRUE

comparator

A function to define the ordering. Currently unused

Details

To ensure proper operations are performed, the ordering of rows and columns within matrix operands must be consistent. Arrange conveniently performs this ordering.

In the future, a comparator will be added so that custom orderings can be applied to the function.

Value

A matrix whose rows and/or columns have been ordered. By default, both rows and columns are ordered.

Examples

1
2

Example output

                 Area Frost HS Grad Illiteracy Income Life Exp Murder
Alabama         50708    20    41.3        2.1   3624    69.05   15.1
Alaska         566432   152    66.7        1.5   6315    69.31   11.3
Arizona        113417    15    58.1        1.8   4530    70.55    7.8
Arkansas        51945    65    39.9        1.9   3378    70.66   10.1
California     156361    20    62.6        1.1   5114    71.71   10.3
Colorado       103766   166    63.9        0.7   4884    72.06    6.8
Connecticut      4862   139    56.0        1.1   5348    72.48    3.1
Delaware         1982   103    54.6        0.9   4809    70.06    6.2
Florida         54090    11    52.6        1.3   4815    70.66   10.7
Georgia         58073    60    40.6        2.0   4091    68.54   13.9
Hawaii           6425     0    61.9        1.9   4963    73.60    6.2
Idaho           82677   126    59.5        0.6   4119    71.87    5.3
Illinois        55748   127    52.6        0.9   5107    70.14   10.3
Indiana         36097   122    52.9        0.7   4458    70.88    7.1
Iowa            55941   140    59.0        0.5   4628    72.56    2.3
Kansas          81787   114    59.9        0.6   4669    72.58    4.5
Kentucky        39650    95    38.5        1.6   3712    70.10   10.6
Louisiana       44930    12    42.2        2.8   3545    68.76   13.2
Maine           30920   161    54.7        0.7   3694    70.39    2.7
Maryland         9891   101    52.3        0.9   5299    70.22    8.5
Massachusetts    7826   103    58.5        1.1   4755    71.83    3.3
Michigan        56817   125    52.8        0.9   4751    70.63   11.1
Minnesota       79289   160    57.6        0.6   4675    72.96    2.3
Mississippi     47296    50    41.0        2.4   3098    68.09   12.5
Missouri        68995   108    48.8        0.8   4254    70.69    9.3
Montana        145587   155    59.2        0.6   4347    70.56    5.0
Nebraska        76483   139    59.3        0.6   4508    72.60    2.9
Nevada         109889   188    65.2        0.5   5149    69.03   11.5
New Hampshire    9027   174    57.6        0.7   4281    71.23    3.3
New Jersey       7521   115    52.5        1.1   5237    70.93    5.2
New Mexico     121412   120    55.2        2.2   3601    70.32    9.7
New York        47831    82    52.7        1.4   4903    70.55   10.9
North Carolina  48798    80    38.5        1.8   3875    69.21   11.1
North Dakota    69273   186    50.3        0.8   5087    72.78    1.4
Ohio            40975   124    53.2        0.8   4561    70.82    7.4
Oklahoma        68782    82    51.6        1.1   3983    71.42    6.4
Oregon          96184    44    60.0        0.6   4660    72.13    4.2
Pennsylvania    44966   126    50.2        1.0   4449    70.43    6.1
Rhode Island     1049   127    46.4        1.3   4558    71.90    2.4
South Carolina  30225    65    37.8        2.3   3635    67.96   11.6
South Dakota    75955   172    53.3        0.5   4167    72.08    1.7
Tennessee       41328    70    41.8        1.7   3821    70.11   11.0
Texas          262134    35    47.4        2.2   4188    70.90   12.2
Utah            82096   137    67.3        0.6   4022    72.90    4.5
Vermont          9267   168    57.1        0.6   3907    71.64    5.5
Virginia        39780    85    47.8        1.4   4701    70.08    9.5
Washington      66570    32    63.5        0.6   4864    71.72    4.3
West Virginia   24070   100    41.6        1.4   3617    69.48    6.7
Wisconsin       54464   149    54.5        0.7   4468    72.48    3.0
Wyoming         97203   173    62.9        0.6   4566    70.29    6.9
               Population
Alabama              3615
Alaska                365
Arizona              2212
Arkansas             2110
California          21198
Colorado             2541
Connecticut          3100
Delaware              579
Florida              8277
Georgia              4931
Hawaii                868
Idaho                 813
Illinois            11197
Indiana              5313
Iowa                 2861
Kansas               2280
Kentucky             3387
Louisiana            3806
Maine                1058
Maryland             4122
Massachusetts        5814
Michigan             9111
Minnesota            3921
Mississippi          2341
Missouri             4767
Montana               746
Nebraska             1544
Nevada                590
New Hampshire         812
New Jersey           7333
New Mexico           1144
New York            18076
North Carolina       5441
North Dakota          637
Ohio                10735
Oklahoma             2715
Oregon               2284
Pennsylvania        11860
Rhode Island          931
South Carolina       2816
South Dakota          681
Tennessee            4173
Texas               12237
Utah                 1203
Vermont               472
Virginia             4981
Washington           3559
West Virginia        1799
Wisconsin            4589
Wyoming               376

futile.matrix documentation built on May 2, 2019, 4:22 a.m.