-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.rmd
78 lines (59 loc) · 4.48 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
---
title: Cluster.OBeu <img src="okfgr2.png" align="right" />
author: "Kleanthis Koupidis, Charalampos Bratsas, Jaroslav Kuchar"
date: "November 9, 2016"
output:
github_document:
fig_width: 8
fig_height: 8
dev: png
html_preview: no
number_sections: yes
---
[![R-CMD-check](https://github.com/okgreece/Cluster.OBeu/workflows/R-CMD-check/badge.svg)](https://github.com/okgreece/Cluster.OBeu/actions)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/Cluster.OBeu)](https://cran.r-project.org/package=Cluster.OBeu)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![](http://cranlogs.r-pkg.org/badges/grand-total/Cluster.OBeu)](http://cran.rstudio.com/web/packages/Cluster.OBeu/index.html)
[![Licence](https://img.shields.io/badge/licence-GPL--2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
[![DOI](https://zenodo.org/badge/65309457.svg)](https://zenodo.org/badge/latestdoi/65309457)
#[Cluster.OBeu](https://okgreece.github.io/Cluster.OBeu/index.html)
Εstimate and return the necessary parameters for cluster analysis visualizations, used in [OpenBudgets.eu](http://openbudgets.eu/).
It involves a set of techniques and algorithms used to find and divide into groups the Budget data of municipalities across Europe, described by the [OpenBudgets.eu data model](https://github.com/openbudgets/data-model).
The available clustering algorithms are hierarchical, kmeans from R base, pam, clara, fuzzy from [cluster package](https://CRAN.R-project.org/package=cluster) and model based algorithms from [mclust package](https://CRAN.R-project.org/package=mclust). It can be used to find the appropriate clustering algorithm and/or the appropriate clustering number of the input data according to the internal and stability measures from [clValid package](https://CRAN.R-project.org/package=clValid).
This package can generally be used to estimate clustering parameters, extract and convert them to JSON format and use them as input in a different graphical interface and also can be used in data that are not described by the [OpenBudgets.eu data model](https://github.com/openbudgets/data-model).
You can see detailed information [here](https://okgreece.github.io/Cluster.OBeu/).
```{r, eval=FALSE, include=TRUE}
# install Cluster.OBeu- cran stable version
install.packages(Cluster.OBeu)
# or
# alternatively install the development version from github
devtools::install_github("okgreece/Cluster.OBeu")
```
Load library `Cluster.OBeu` <img src="obeu_logo.png" align="right" />
```{r}
library(Cluster.OBeu)
```
#Cluster Analysis in a call
`cl.analysis` can be used to estimate clustering model parameters and/or number of clusters needed for visualization of clusters and other clustering measures as list object.
```{r eval=FALSE, message=FALSE, warning=FALSE, include=TRUE }
cluster_data = cl.analysis( city_data, cl.aggregate = "sum",
cl.meth = "pam", clust.numb = NULL, dist = "euclidean", tojson = T) # json string format
jsonlite::prettify(cluster_data) # use prettify of jsonlite library to add indentation to the returned JSON string
```
#Cluster Analysis on OpenBudgets.eu platform
`open_spending.cl` is designed to estimate and return the clustering model measures of [OpenBudgets.eu](http://openbudgets.eu/) datasets.
The input data must be a JSON link according to the [OpenBudgets.eu data model](https://github.com/openbudgets/data-model). There are different parameters that a user could specify, e.g. `dimensions`, `measured.dimensions` and `amounts` should be defined by the user, to form the dimensions of the dataset. `open_spending.cl` estimates and returns the json data that are described with the [OpenBudgets.eu data model](https://github.com/openbudgets/data-model), using `cl.analysis` function.
```{r eval=FALSE, message=FALSE, warning=FALSE, include=TRUE}
#Store the link in a variable
json_link='http://ws307.math.auth.gr/rudolf/public/api/3/cubes/budget-athens-revenue-2007__93458/aggregate?drilldown=budgetPhase.prefLabel%7CadministrativeClassification.prefLabel&aggregates=amount.sum'
clustering = open_spending.cl(
json_data = json_link,
dimensions ="administrativeClassification.prefLabel",
measured.dimensions ="budgetPhase.prefLabel",
amounts = "amount.sum",
cl.method = "fanny",
cl.num = 3
)
# Pretty output using prettify of jsonlite library
jsonlite::prettify(clustering,indent = 2)
```