-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.Rmd
106 lines (77 loc) · 2.1 KB
/
demo.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
---
title: "Demo"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{demo}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(ODataQuery)
```
## Introduction
Here I'll show some examples to use this package
## Create service
```{r}
service <- ODataQuery$new("https://services.odata.org/V4/TripPinServiceRW")
service$all()
```
## Entity set
```{r}
people_entity <- service$path("People")
# Get first page
people_entity$retrieve(count=TRUE)
# Get all pages
people_entity$select("UserName", "FirstName", "LastName")$all()
```
## Singleton
```{r}
russellwhyte <- people_entity$get("russellwhyte")
first_person <- people_entity$top(1)$one()
head(first_person)
russellwhyte_friends <- russellwhyte$path("Friends")
russellwhyte_friends$all()
```
## Function call
```{r}
get_nearest_airport <- service$func('GetNearestAirport')
get_nearest_airport(lat = 33, lon = -118)
```
## Querying
```{r}
people_query <- people_entity$
top(5)$
select('FirstName', 'LastName')$
filter(Concurrency.gt = 500)$
expand('Friends($count=true)')$
orderby('LastName')
people_query$all()
```
## Other endpoints
### Statistics, the Netherlands
```{r eval=FALSE}
opendata_service <- ODataQuery$new("http://beta-odata4.cbs.nl/")
entity_81589NED <- opendata_service$path("CBS", "81589NED", "Observations")
dataset_81589NED <- entity_81589NED$all()
```
### Northwind (OData v2)
Connecting with older OData v2 works, but some features have been changed.
```{r eval=FALSE}
northwind_service <- ODataQuery$new("https://services.odata.org/V2/Northwind/Northwind.svc/")
customer_entity <- northwind_service$path("Customers")
customer_entity$
select("CompanyName", "Address", "Phone")$
filter(Country.eq = "Germany", City.eq = "Berlin")
```
### The Hague
So far, I haven't been able to figure out how their data model works, but at least we can connect to it.
```{r eval=FALSE}
denhaag_service <- ODataQuery$new("https://denhaag.incijfers.nl/jiveservices/odata/")
denhaag_service$path('DataSources')
```