-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
103 lines (73 loc) · 2.62 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
---
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%"
)
```
# meteoR
<!-- badges: start -->
[![R-CMD-check](https://github.com/thieled/meteoR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thieled/meteoR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
meteoR is an unofficial R wrapper around the [OPTED Meteor API](https://meteor.opted.eu/).
## Installation
You can install the development version of meteoR from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("thieled/meteoR")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(meteoR)
# Get the country uid from the API
countries <- call_meteor(method = "get",
ressource = "query",
type = "Country",
format = "dataframe"
)
channel <- call_meteor(method = "get",
ressource = "query",
type = "Channel",
format = "dataframe"
)
channel_website <- dplyr::filter(channel, `_unique_name` == "website")
countries_selection <- countries |> dplyr::filter(name %in% c("Austria",
"Germany"))
# Query the API for news sources from these countries
news_sources <- call_meteor(method = "get",
ressource = "query",
type = "NewsSource",
countries = countries_selection$uid,
channel = channel_website$uid,
geographic_scope = c("national"),
format = "dataframe",
publication_kind = c("newspaper", "magazine"),
n_max = 10, n = 10
)
# Get more insights
view_df <- view_uid(uid = news_sources$uid,
format = "dataframe",
unnest_cutoff = 1)
dplyr::glimpse(view_df)
# Get follower count from external API call:
call_ws <- function(website
){
r <- call_meteor(method = "post",
ressource = "external",
option = "website",
website = website,
format = "raw"
)
return(r)
}
# Apply
res <- pbapply::pblapply(head(view_df, 3)$identifier, FUN = call_ws)
res <- fleece::rectangularize(res)
dplyr::glimpse(res)
```