-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
115 lines (86 loc) · 3.75 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# `socialranking`
<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/jassler/socialranking/branch/main/graph/badge.svg)](https://app.codecov.io/gh/jassler/socialranking?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/socialranking)](https://CRAN.R-project.org/package=socialranking)
<!-- badges: end -->
The package `socialranking` offers functions to represent ordinal
information of coalitions and calculate the power relation between elements or players.
## Installation
Install the package directly from [CRAN](https://cran.r-project.org/package=socialranking) with:
``` r
install.packages("socialranking")
```
You can also install the development version of socialranking from [GitHub](https://github.com/jassler/socialranking) with:
``` r
# install.packages("devtools")
devtools::install_github("jassler/socialranking")
```
## Usage
The package `socialranking` offers functions to represent ordinal
information of coalitions and calculate the power relation between elements or players.
Once installed, call `library(socialranking)` to load the package into your current environment.
`PowerRelation()` and `as.PowerRelation()` creates a `PowerRelation` object. `createPowerset()`
is a convenient function to generate a `PowerRelation()` or `as.PowerRelation()` function call
for all possible coalitions.
```{r}
library(socialranking)
if(interactive()) {
createPowerset(1:3, copyToClipboard = TRUE)
}
# pasted, rearranged, adjusted comparators
as.PowerRelation("
123
> 12
~ 13
> 2
~ 23
> 1
> 3
")
# equivalent
pr <- as.PowerRelation(
list(c(1,2,3), c(1,2), c(1,3), c(2), c(2,3), c(1), c(3)),
comparators = c(">", "~", ">", "~", ">", ">")
)
# equivalent
pr <- as.PowerRelation("123 > 12 ~ 13 > 2 ~ 23 > 1 > 3")
pr
pr$elements
pr$eqs[[2]]
```
The functions used to analyze power relations can be grouped into comparison functions,
score functions and ranking solutions. Ranking solutions produce a `SocialRankingSolution` object.
| Comparison Functions | Score Functions | Ranking Solutions |
|----------------------------|--------------------------|---------------------------|
| `dominates()` | | |
| `cumulativelyDominates()` | `cumulativeScores()` | |
| `cpMajorityComparison()`^1 | `copelandScores()` | `copelandRanking()` |
| | `kramerSimpsonScores()` | `kramerSimpsonRanking()` |
| | `ordinalBanzhafScores()` | `ordinalBanzhafRanking()` |
| | `lexcelScores()` | `lexcelRanking()` |
| | | `dualLexcelRanking()` |
| | `L1Scores()` | `L1Ranking()` |
| | `LPScores()` | `LPRanking()` |
| | `LPSScores()` | `LPSRanking()` |
^1 `cpMajorityComparisonScore()` is a faster alternative to `cpMajorityComparison()`, but it produces less data.
```{r}
dominates(pr, 1, 2)
copelandRanking(pr)
lexcelScores(pr, 1)
```
`PowerRelation` objects can be turned into `relations` objects from the [relations](https://CRAN.R-project.org/package=relations) package using `powerRelationMatrix()` or `as.relation()`.
Use `browseVignettes("socialranking")` for further information.
## License
This package is licensed under [GPL-3](https://choosealicense.com/licenses/gpl-3.0/#).