sortC: Returns case-level information in order

Description Usage Arguments Value Examples

View source: R/sortC.r

Description

Returns case-level information in order specified by user.

Usage

1
sortC(data, id, by, descending = TRUE)

Arguments

data

Dataset to be sorted.

id

A variable in the dataset (data) that identfies individual cases, typically the name of states, countries, etc.

by

Variable the dataset should be sorted by.

descending

Should the cases be sorted in descending order? By default, set to TRUE.

Value

A data frame of sorted observations.

Examples

1
2
3
4
5
   library(poliscidata)
   
   sortC(data=states, id=state, by=abortlaw10)
   
   sortC(data=states, id=state, by=abortlaw10, descending=FALSE)

Example output

                                        state abortlaw10
15 Indiana                                            10
36 Oklahoma                                           10
40 SouthCarolina                                      10
3  Arkansas                                            9
10 Georgia                                             9
13 Idaho                                               9
18 Louisiana                                           9
24 Missouri                                            9
28 NorthDakota                                         9
41 SouthDakota                                         9
44 Utah                                                9
45 Virginia                                            9
48 Wisconsin                                           9
2  Alabama                                             8
16 Kansas                                              8
22 Michigan                                            8
23 Minnesota                                           8
29 Nebraska                                            8
35 Ohio                                                8
38 Pennsylvania                                        8
9  Florida                                             7
17 Kentucky                                            7
25 Mississippi                                         7
42 Tennessee                                           7
43 Texas                                               7
4  Arizona                                             6
12 Iowa                                                6
14 Illinois                                            6
19 Massachusetts                                       6
26 Montana                                             6
27 NorthCarolina                                       6
33 Nevada                                              6
39 RhodeIsland                                         6
1  Alaska                                              5
8  Delaware                                            5
31 NewJersey                                           5
50 Wyoming                                             5
5  California                                          4
6  Colorado                                            4
7  Connecticut                                         4
21 Maine                                               4
49 WestVirginia                                        4
20 Maryland                                            3
32 NewMexico                                           3
34 NewYork                                             3
11 Hawaii                                              2
47 Washington                                          2
30 NewHampshire                                        1
37 Oregon                                              1
46 Vermont                                             0
                                        state abortlaw10
46 Vermont                                             0
30 NewHampshire                                        1
37 Oregon                                              1
11 Hawaii                                              2
47 Washington                                          2
20 Maryland                                            3
32 NewMexico                                           3
34 NewYork                                             3
5  California                                          4
6  Colorado                                            4
7  Connecticut                                         4
21 Maine                                               4
49 WestVirginia                                        4
1  Alaska                                              5
8  Delaware                                            5
31 NewJersey                                           5
50 Wyoming                                             5
4  Arizona                                             6
12 Iowa                                                6
14 Illinois                                            6
19 Massachusetts                                       6
26 Montana                                             6
27 NorthCarolina                                       6
33 Nevada                                              6
39 RhodeIsland                                         6
9  Florida                                             7
17 Kentucky                                            7
25 Mississippi                                         7
42 Tennessee                                           7
43 Texas                                               7
2  Alabama                                             8
16 Kansas                                              8
22 Michigan                                            8
23 Minnesota                                           8
29 Nebraska                                            8
35 Ohio                                                8
38 Pennsylvania                                        8
3  Arkansas                                            9
10 Georgia                                             9
13 Idaho                                               9
18 Louisiana                                           9
24 Missouri                                            9
28 NorthDakota                                         9
41 SouthDakota                                         9
44 Utah                                                9
45 Virginia                                            9
48 Wisconsin                                           9
15 Indiana                                            10
36 Oklahoma                                           10
40 SouthCarolina                                      10

poliscidata documentation built on July 8, 2020, 6:23 p.m.