From 7bf1b98b83d59bdd60e4451efef3dfbecb77925e Mon Sep 17 00:00:00 2001 From: maelle Date: Thu, 19 Oct 2023 08:49:41 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20lvaudor/?= =?UTF-8?q?glitter@f89f4c9c060b9b12ea1a0cdf3b05a00e303df132=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- articles/explore.html | 76 +++++++++++++++--------------- articles/glitter_for_Wikidata.html | 46 +++++++++--------- articles/glitter_for_dataBNF.html | 12 ++--- pkgdown.yml | 2 +- reference/spq_select.html | 30 ++++++++++-- reference/spq_tally.html | 16 +++---- search.json | 2 +- 7 files changed, 103 insertions(+), 81 deletions(-) diff --git a/articles/explore.html b/articles/explore.html index 5913fff..1b26da3 100644 --- a/articles/explore.html +++ b/articles/explore.html @@ -398,7 +398,7 @@

Which classes have the most insta https://cube.link/Observation -8783140 +8783162 https://www.ica.org/standards/RiC/ontology#DateRange @@ -410,11 +410,11 @@

Which classes have the most insta http://schema.org/DefinedTerm -2990868 +2991194 http://schema.org/PropertyValue -2198567 +2199533 http://schema.org/Place @@ -422,39 +422,39 @@

Which classes have the most insta http://schema.org/PostalAddress -743990 +744309 http://schema.org/Organization -740486 +740813 https://schema.ld.admin.ch/ZefixOrganisation -732943 +733269 http://www.w3.org/ns/locn#Address -732766 +733088 http://filteredpush.org/ontologies/oa/dwcFP#TaxonConcept -673891 +674604 http://filteredpush.org/ontologies/oa/dwcFP#TaxonName -656276 +657190 http://plazi.org/vocab/treatment#Treatment -649894 +650936 http://purl.org/spar/fabio/JournalArticle -323064 +323150 http://purl.org/spar/fabio/Figure -312476 +312938 https://ld.zh.ch/elodzh-ontology/Man @@ -474,7 +474,7 @@

Which classes have the most insta http://rs.tdwg.org/dwc/terms/MaterialCitation -208636 +209256 @@ -504,7 +504,7 @@

Which classes have the most insta https://cube.link/Observation -8783140 +8783162 Date Range @@ -519,12 +519,12 @@

Which classes have the most insta http://schema.org/DefinedTerm -2990868 +2991194 http://schema.org/PropertyValue -2198567 +2199533 @@ -534,47 +534,47 @@

Which classes have the most insta http://schema.org/PostalAddress -743990 +744309 http://schema.org/Organization -740486 +740813 https://schema.ld.admin.ch/ZefixOrganisation -732943 +733269 http://www.w3.org/ns/locn#Address -732766 +733088 http://filteredpush.org/ontologies/oa/dwcFP#TaxonConcept -673891 +674604 http://filteredpush.org/ontologies/oa/dwcFP#TaxonName -656276 +657190 http://plazi.org/vocab/treatment#Treatment -649894 +650936 http://purl.org/spar/fabio/JournalArticle -323064 +323150 http://purl.org/spar/fabio/Figure -312476 +312938 Man @@ -599,7 +599,7 @@

Which classes have the most insta http://rs.tdwg.org/dwc/terms/MaterialCitation -208636 +209256 @@ -740,43 +740,43 @@

What values does a given propert ZH -128297 +128343 BE -66481 +66512 VD -64187 +64251 GE -53751 +53806 AG -43383 +43390 TI -41977 +41986 SG -40514 +40557 ZG -39677 +39717 LU -32943 +32953 VS -32308 +32332 @@ -817,7 +817,7 @@

What data is stored about spq_prefix(prefixes = c("schema" = "http://schema.org/")) %>% spq_add("?s a schema:Organization") %>% spq_add("?s ?property ?value") %>% - spq_select(-value, -s, class, .spq_duplicate = "distinct") %>% + spq_select(-value, -s, .spq_duplicate = "distinct") %>% spq_perform() %>% knitr::kable() @@ -975,7 +975,7 @@

What data is stored about spq_prefix(prefixes = c("schema" = "http://schema.org/")) %>% spq_add("?s a schema:PostalAddress") %>% spq_add("?s ?property ?value") %>% - spq_select(-value, -s, class, .spq_duplicate = "distinct") %>% + spq_select(-value, -s, .spq_duplicate = "distinct") %>% spq_perform() %>% knitr::kable()

diff --git a/articles/glitter_for_Wikidata.html b/articles/glitter_for_Wikidata.html index cfbfa1f..7ca91ba 100644 --- a/articles/glitter_for_Wikidata.html +++ b/articles/glitter_for_Wikidata.html @@ -244,12 +244,12 @@

Add another triple pattern#> # A tibble: 6 × 1 #> station #> <chr> -#> 1 Place Guichard - Bourse du Travail -#> 2 Hôtel de Ville - Louis Pradel -#> 3 Cordeliers -#> 4 Gare de Vénissieux -#> 5 Stade de Gerland -#> 6 Saxe - Gambetta +#> 1 Gare d'Oullins +#> 2 Place Guichard - Bourse du Travail +#> 3 Hôtel de Ville - Louis Pradel +#> 4 Cordeliers +#> 5 Gare de Vénissieux +#> 6 Stade de Gerland +#> 1 Point(4.814544444 45.716669444) Gare d'Oullins +#> 2 Point(4.847308333 45.759261111) Place Guichard - Bourse du Travail +#> 3 Point(4.836022222 45.767377777) Hôtel de Ville - Louis Pradel +#> 4 Point(4.835894444 45.763511111) Cordeliers +#> 5 Point(4.88804 45.7058) Gare de Vénissieux +#> 6 Point(4.83038 45.7272) Stade de Gerland

This tibble can be transformed into a Simple feature collection (sfc) object using package sf:

+#> 1 (4.814544 45.71667) Gare d'Oullins +#> 2 (4.847308 45.75926) Place Guichard - Bourse du Travail +#> 3 (4.836022 45.76738) Hôtel de Ville - Louis Pradel +#> 4 (4.835894 45.76351) Cordeliers +#> 5 (4.88804 45.7058) Gare de Vénissieux +#> 6 (4.83038 45.7272) Stade de Gerland

The resulting object may then be used easily with (for instance) package leaflet:

 leaflet(stations_sf) %>%
   addTiles() %>%
   addCircles(popup = ~station)
-
- +
+
@@ -440,8 +440,8 @@

Add property qualifiers addCircles(popup=~station) %>% addPolylines(data=stations_lines_sf, color=~factpal(line), popup=~line)

-
- +
+ diff --git a/articles/glitter_for_dataBNF.html b/articles/glitter_for_dataBNF.html index da66bbe..41e5788 100644 --- a/articles/glitter_for_dataBNF.html +++ b/articles/glitter_for_dataBNF.html @@ -999,17 +999,17 @@

Portraits d’auteur, issus de Galli

- - - - - - + + + + + + diff --git a/pkgdown.yml b/pkgdown.yml index f2109dc..12a9b27 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -7,7 +7,7 @@ articles: glitter_for_Wikidata: glitter_for_Wikidata.html glitter_for_dataBNF: glitter_for_dataBNF.html internals: internals.html -last_built: 2023-10-12T15:27Z +last_built: 2023-10-19T08:43Z urls: reference: https://lvaudor.github.io/glitter/reference article: https://lvaudor.github.io/glitter/articles diff --git a/reference/spq_select.html b/reference/spq_select.html index 69cdccc..dab6cca 100644 --- a/reference/spq_select.html +++ b/reference/spq_select.html @@ -87,13 +87,35 @@

Value

Examples


-query = spq_init()
-spq_select(query, count = n (human), eyecolor_label, haircolor_label)
-#> 
-#> SELECT (COUNT(?human) AS ?count) ?eyecolor_label ?haircolor_label
+spq_init() |>
+  spq_prefix(prefixes = c(dct = "http://purl.org/dc/terms/")) |>
+  spq_add(spq('?lexemeId dct:language wd:Q1860')) |>
+  spq_add(spq("?lexemeId wikibase:lemma ?lemma")) |>
+  spq_filter(str_detect(lemma, '^pota.*')) |>
+  spq_select(- lemma)
+#> PREFIX dct: <http://purl.org/dc/terms/>
+#> SELECT ?lexemeId
 #> WHERE {
 #> 
+#> ?lexemeId dct:language wd:Q1860.
+#> ?lexemeId wikibase:lemma ?lemma.
+#> FILTER(REGEX(?lemma,"^pota.*"))
+#> }
+#> 
+
+spq_init() |>
+  spq_prefix(prefixes = c(dct = "http://purl.org/dc/terms/")) |>
+  spq_add(spq('?lexemeId dct:language wd:Q1860')) |>
+  spq_add(spq("?lexemeId wikibase:lemma ?lemma")) |>
+  spq_filter(str_detect(lemma, '^pota.*')) |>
+  spq_select(lemma)
+#> PREFIX dct: <http://purl.org/dc/terms/>
+#> SELECT ?lemma
+#> WHERE {
 #> 
+#> ?lexemeId dct:language wd:Q1860.
+#> ?lexemeId wikibase:lemma ?lemma.
+#> FILTER(REGEX(?lemma,"^pota.*"))
 #> }
 #> 
 
diff --git a/reference/spq_tally.html b/reference/spq_tally.html index c92b622..1a79343 100644 --- a/reference/spq_tally.html +++ b/reference/spq_tally.html @@ -106,7 +106,7 @@

Examples#> # A tibble: 1 × 1 #> n_films #> <int> -#> 1 51165 +#> 1 51171 # the same with spq_count @@ -119,7 +119,7 @@

Examples#> # A tibble: 1 × 1 #> n_films #> <int> -#> 1 51165 +#> 1 51171 # Now with grouping spq_init() %>% @@ -129,7 +129,7 @@

Examplesspq_group_by(narrative_location_label) %>% spq_tally(sort = TRUE, name = "n_films") %>% spq_perform() -#> # A tibble: 2,747 × 2 +#> # A tibble: 2,750 × 2 #> narrative_location_label n_films #> <chr> <int> #> 1 Indonesia 3088 @@ -138,11 +138,11 @@

Examples#> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 -#> 7 Rome 968 +#> 7 Rome 969 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 -#> # ℹ 2,737 more rows +#> # ℹ 2,740 more rows # More direct with spq_count() @@ -152,7 +152,7 @@

Examplesspq_label(film, narrative_location) %>% spq_count(narrative_location_label, sort = TRUE, name = "n_films") %>% spq_perform() -#> # A tibble: 2,747 × 2 +#> # A tibble: 2,750 × 2 #> narrative_location_label n_films #> <chr> <int> #> 1 Indonesia 3088 @@ -161,11 +161,11 @@

Examples#> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 -#> 7 Rome 968 +#> 7 Rome 969 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 -#> # ℹ 2,737 more rows +#> # ℹ 2,740 more rows # } diff --git a/search.json b/search.json index eb01daf..9f5b0f6 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement lise.vaudor@ens-lyon.fr. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"a-word-of-caution","dir":"Articles","previous_headings":"","what":"A word of caution","title":"How to explore a new database with glitter","text":"Depending dataset (triplestore, context) ’re working , queries might just ask much service proceed caution. doubt, add spq_head() query pipeline, ask less time, use spq_count() get sense many results total.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"asking-for-a-subset-of-all-triples","dir":"Articles","previous_headings":"","what":"Asking for a subset of all triples","title":"How to explore a new database with glitter","text":"code ’ll ask 10 triples. Note use endpoint argument spq_init() indicate send query, well request_type argument. can one know whether service needs request_type = \"body-form\"? docs might mention . Trial error. LINDAS’ case run request via https://lindas.admin.ch/sparql/ use browser’s web developer console request tab, can see request sends query body. first query helpful shows can query! results however can … less helpful.","code":"library(\"glitter\") query_basis = spq_init( endpoint = \"https://ld.admin.ch/query\", request_control = spq_control_request( request_type = \"body-form\" ) ) query_basis %>% spq_add(\"?s ?p ?o\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"find-which-classes-are-declared","dir":"Articles","previous_headings":"Classes","what":"Find which classes are declared","title":"How to explore a new database with glitter","text":"classes occurring database provide information kind data find . can varied (across triplestores, even single triplestore) people, places, buildings, trees, even things abstract like concepts, philosophical currents, historical periods, etc. point might think need use prefixes query. prefixes present glitter::usual_prefixes, don’t need anything. ’re , use glitter::spq_prefix(). many classes defined total? query might big service. 1195 classes declared triplestore. many get one query, definitely many show ! Let us examine classes: now still dark service provides.","code":"query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable() nclasses = query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_count() %>% spq_perform() nclasses #> # A tibble: 1 × 1 #> n #> #> 1 1195 query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-classes-have-instances","dir":"Articles","previous_headings":"Classes","what":"Which classes have instances?","title":"How to explore a new database with glitter","text":"class might declared although even items fall . Getting classes instances actually corresponds another triple pattern, “?item instance ?class”, .k.. “?item ?class”:","code":"query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(- instance) %>% spq_arrange(class) %>% spq_head(n = 10) %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-classes-have-the-most-instances","dir":"Articles","previous_headings":"Classes","what":"Which classes have the most instances?","title":"How to explore a new database with glitter","text":"number items falling class actually gives even better overview contents triplestore: case class names quite self explanatory use","code":"query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_count(class, sort = TRUE) %>% # count items falling under class spq_head(20) %>% spq_perform() %>% knitr::kable() query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_label(class) %>% # label class to get class_label spq_count(class, class_label, sort = TRUE) %>% # group by class and class_label to count spq_head(20) %>% spq_perform() %>% knitr::kable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"find-which-properties-are-declared","dir":"Articles","previous_headings":"Properties","what":"Find which properties are declared","title":"How to explore a new database with glitter","text":"Note instead use spq_add(\"?property rdfs:Property\") case returned nothing. many properties defined total? query might big service.","code":"query_basis %>% spq_add(\"?property a owl:DatatypeProperty\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable() query_basis %>% spq_add(\"?property a owl:DatatypeProperty\") %>% spq_count() %>% spq_perform() #> # A tibble: 1 × 1 #> n #> #> 1 241"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-properties-are-used","dir":"Articles","previous_headings":"Properties","what":"What properties are used?","title":"How to explore a new database with glitter","text":"Similarly counting instances classes, wish get sense properties actually used triplestore.","code":"query_basis %>% spq_add(\"?s ?property ?o\") %>% spq_select(- s, - o) %>% spq_select(property, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-values-does-a-given-property-have","dir":"Articles","previous_headings":"Properties","what":"What values does a given property have?","title":"How to explore a new database with glitter","text":"","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\"))%>% spq_add(\"?s schema:addressRegion ?value\") %>% spq_count(value, sort = TRUE) %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-class-use-a-particular-property","dir":"Articles","previous_headings":"","what":"Which class use a particular property?","title":"How to explore a new database with glitter","text":"One properties https://gont.ch/longName. class uses ?","code":"query_basis %>% spq_prefix(prefixes = c(\"gont\" = \"https://gont.ch/\")) %>% spq_add(\"?s gont:longName ?o\") %>% spq_add(\"?s a ?class\") %>% spq_select(-o, -s) %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-data-is-stored-about-a-classs-instances","dir":"Articles","previous_headings":"","what":"What data is stored about a class’s instances?","title":"How to explore a new database with glitter","text":"items falling given class likely subject (object) common set properties. One might wish explore properties actually associated class. instance, LINDAS, properties schema:Organization class associated ? properties schema:PostalAddress class associated ?","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:Organization\") %>% spq_add(\"?s ?property ?value\") %>% spq_select(-value, -s, class, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable() query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:PostalAddress\") %>% spq_add(\"?s ?property ?value\") %>% spq_select(-value, -s, class, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-data-or-property-name-includes-a-certain-substring","dir":"Articles","previous_headings":"","what":"Which data or property name includes a certain substring?","title":"How to explore a new database with glitter","text":"Let us examine whether exists LINDAS data related water, search string “hydro” “Hydro” :","code":"query_basis %>% spq_add(\"?s ?p ?o\") %>% spq_filter(str_detect(o, \"[Hh]ydro\")) %>% spq_select(-s, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"an-example-query-based-on-what-we-now-know","dir":"Articles","previous_headings":"","what":"An example query based on what we now know","title":"How to explore a new database with glitter","text":"wrap , let us now use LINDAS triplestore actual data query: instance try collect organizations “swiss” name:","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:Organization\") %>% spq_add(\"?s schema:name ?name\") %>% spq_filter(str_detect(name, \"swiss\")) %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"requête-de-base","dir":"Articles","previous_headings":"","what":"Requête de base","title":"glitter for HAL (en français)","text":"Afin de ne pas trop en demander à HAL, créons une requête de base qui n’envoient pas trop de requêtes d’un coup.","code":"hal_basic_request <- spq_init( \"hal\", request_control = spq_control_request(rate = 3/60) )"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"entrée-par-auteurrice","dir":"Articles","previous_headings":"","what":"Entrée par auteur·rice","title":"glitter for HAL (en français)","text":"Essayons par exemple d’examiner s’il existe dans la base quelqu’un qui s’appelle (tout à fait au hasard) “Lise Vaudor”: plot chunk test_LV Il existe bien une personne ayant ce nom dans la base de données, qui fait l’objet d’une fiche consultable. La consultation de cette page montre que deux propriétés sont souvent renseignées: foaf:interest et foaf:topic_interest. Cette dernière propriété semble regrouper des mots-clés issus de l’ensemble des publications de l’auteur alors que foaf:interest correspond à des centres d’intérêt déclarés (probablement lors de la création du profil HAL: à vrai dire je ne m’en souviens plus!). Quoi qu’il en soit, l’information relative aux centres d’intérêt est accessible comme suit: plot chunk interet_LV plot chunk interet_LV_run","code":"test_LV = hal_basic_request %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% # récupère les personnes appelées \"Lise Vaudor\" spq_perform() DT::datatable(test_LV) requete = hal_basic_request %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?personne foaf:interest ?interet\") %>% # récupère les centres d'intérêt spq_label(interet, .languages = \"fr\") # étiquette les centres d'intérêt sequins::graph_query(requete, layout = \"tree\") interet_LV = requete %>% # garde seulement les étiquettes en français spq_perform() DT::datatable(interet_LV)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"documents-dune-auteurrice","dir":"Articles","previous_headings":"","what":"Documents d’un·e auteur·rice","title":"glitter for HAL (en français)","text":"Une des petites subtilités du modèle de données HAL consiste à considérer que un document un créateur·rice – ou auteur·rice – et un·e créateur·rice correspond à une personne.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"affiliations","dir":"Articles","previous_headings":"Documents d’un·e auteur·rice","what":"Affiliations","title":"glitter for HAL (en français)","text":"Par exemple, l’article “sampling influences statistical power detect changes abundance: application river restoration” pour créatrice (entre autres personnes) “Lise Vaudor à l’époque du Cemagref”, qui correspond à la personne “Lise Vaudor” qui elle est intemporelle 😉. Ainsi, c’est en considérant les créateurs de documents que l’va récupérer les affiliations: l’affiliation est une information qui se récupère en adoptant une entrée par document plutôt que par auteur·rice. plot chunk orga_LV_prep plot chunk orga_LV_run","code":"requete = hal_basic_request %>% spq_add(\"?doc dcterms:creator ?createur\") %>% # documents crées par créateur spq_add(\"?createur hal:structure ?affiliation\") %>% # créateur correspond à une affiliation spq_add(\"?createur hal:person ?personne\") %>% # créateur correspond à une personne spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_label(affiliation, .overwrite = TRUE, .languages = NULL) %>% # étiquette affiliation spq_group_by(affiliation) %>% # groupe par affiliation spq_summarise(n = n()) %>% spq_arrange(desc(n)) requete ## PREFIX foaf: ## PREFIX dcterms: ## PREFIX skos: ## PREFIX hal: ## SELECT ?affiliation (COUNT(*) AS ?n) ## WHERE { ## ## ?doc dcterms:creator ?createur. ## ?createur hal:structure ?affiliation0. ## ?createur hal:person ?personne. ## ?personne foaf:name 'Lise Vaudor'. ## OPTIONAL {?affiliation0 skos:prefLabel ?affiliation_labell.} ## BIND(COALESCE(?affiliation_labell,'') AS ?affiliation) ## ## } ## GROUP BY ?affiliation ## ORDER BY DESC(?n) sequins::graph_query(requete, layout=\"tree\") orga_LV = requete %>% # renvoie le nombre d'enregistrements spq_perform() DT::datatable(orga_LV)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"documents","dir":"Articles","previous_headings":"Documents d’un·e auteur·rice","what":"Documents","title":"glitter for HAL (en français)","text":"Si l’ne s’intéresse pas aux affiliations mais aux documents eux-mêmes: Cette requête renvoie une table comptant 106. Voici les 20 documents les plus récents: plot chunk docs_LV_recents","code":"docs_LV = hal_basic_request %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_add(\"?createur hal:structure ?affiliation\") %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_label(affiliation, .overwrite = TRUE, .languages = NULL) %>% spq_add(\"?doc dcterms:type ?type\") %>% spq_label(type, .languages = \"fr\") %>% spq_add(\"?doc dcterms:bibliographicCitation ?citation\") %>% spq_add(\"?doc dcterms:issued ?date\") %>% spq_mutate(date = str_sub(as.character(date), 1, 4)) %>% spq_group_by(citation, type_label, date) %>% spq_summarise(affiliation = str_c(affiliation, sep = \", \")) %>% spq_perform() docs_LV ## # A tibble: 106 × 4 ## citation date type_label affiliation ## ## 1 \"Lise Vaudor, E. Parrot, Hervé Piégay. Describi… 2013 Poster de… Plateforme… ## 2 \"Lise Vaudor, Sébastien Rey-Coyrehourcq, Fabien… 2018 Note de l… Environnem… ## 3 \"Lise Vaudor, Hervé Piégay, Vincent Wawrzyniak,… 2016 Communica… Environnem… ## 4 \"Véronique Benacchio, Hervé Piégay, Thomas Buff… 2017 Article d… Environnem… ## 5 \"V. Benacchio, Hervé Piégay, Thomas Buffin-Bela… 2014 Communica… Environnem… ## 6 \"Thomas Buhler, Emeline Comby, Lise Vaudor, Thi… 2021 Article d… Environnem… ## 7 \"Matthieu Adam, Marylise Cottet, Sylvie Morarde… 2020 Article d… Environnem… ## 8 \"Bastien Bonef, Lionel Gérard, Jean-Luc Rouvièr… 2015 Article d… Nanophysiq… ## 9 \"Hervé Piégay, Fanny Arnaud, Cassel Mathieu, Th… 2016 Article d… Environnem… ## 10 \"Jérémie Riquier, Hervé Piégay, Nicolas Lamouro… 2016 Communica… Environnem… ## # ℹ 96 more rows docs_LV %>% arrange(desc(date)) %>% head(20) %>% DT::datatable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"identification-du-laboratoire","dir":"Articles","previous_headings":"Entrée par laboratoire","what":"Identification du laboratoire","title":"glitter for HAL (en français)","text":"Intéressons-nous maintenant aux publications issues d’un laboratoire. Ici, nous avons choisi le laboratoire “Environnement Ville Société”, alias “EVS” ou encore “UMR 5600”. Essayons de le retrouver dans la base de données: Bon! Eh bien, étant donné la diversité des formats dans la dénomination d’EVS, un petit tri manuel s’impose. plot chunk labo_EVS_filter Créons maintenant une fonction qui permet de récupérer l’ensemble des documents pour chacune de ces dénominations de laboratoire. Appliquons maintenant cette fonction à chacune des dénominations possibles pour le labo EVS: Cette table compte de nombreux enregistrements. montre ci-dessous les plus récents (à partir de 2020):","code":"labo_EVS = hal_basic_request %>% spq_label(labo, .languages = NULL, .required = TRUE) %>% spq_add(\"?labo dcterms:identifier ?labo_id\", .required = FALSE) %>% spq_filter(str_detect(labo_label,\"EVS|(UMR 5600)|(Environnement Ville Soc)\")) %>% spq_perform() labo_EVS ## # A tibble: 21 × 3 ## labo labo_label labo_id ## ## 1 https://data.archives-ouvertes.fr/revue/36364 REVSTAT - Statist… ## 2 https://data.archives-ouvertes.fr/revue/115361 Issue 4 of SCS Tr… ## 3 https://data.archives-ouvertes.fr/structure/54063 GEVSM ## 4 https://data.archives-ouvertes.fr/structure/145345 Environnement Vil… UMR5600 ## 5 https://data.archives-ouvertes.fr/structure/390864 UMR 5600 EVS ## 6 https://data.archives-ouvertes.fr/structure/458855 Plateforme ISIG. … ## 7 https://data.archives-ouvertes.fr/structure/493368 Environnement Vil… ## 8 https://data.archives-ouvertes.fr/structure/516259 UMR CNRS 5600 EVS… ## 9 https://data.archives-ouvertes.fr/structure/516301 Environnement Vil… ## 10 https://data.archives-ouvertes.fr/structure/520344 EVS-LAURE UMR 56… ## # ℹ 11 more rows labo_EVS = labo_EVS %>% unique() %>% mutate(num = 1:n()) %>% filter(!(num %in% c(1,2,3,18))) %>% # ici je retire les labos qui ne correspondent pas à UMR 5600 / EVS select(-num) DT::datatable(labo_EVS) get_docs_lab = function(lab){ Sys.sleep(30) # extra-safe lab = paste0(\"<\",lab,\">\") result = hal_basic_request %>% spq_add(glue::glue(\"?createur hal:structure {lab}\")) %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name ?auteur\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_select(-createur) %>% spq_label(type, .languages = \"fr\") %>% # étiquette le type de document en français spq_add(\"?doc dcterms:bibliographicCitation ?citation\") %>% # récupère la citation spq_add(\"?doc dcterms:issued ?date\") %>% spq_perform() %>% mutate(date = stringr::str_sub(date,1,4)) %>% select(auteur, type = type_label, date, citation) return(result) } docs_EVS = labo_EVS %>% group_by(labo, labo_label) %>% tidyr::nest() %>% mutate(data = purrr::map(labo, get_docs_lab)) %>% tidyr::unnest(cols=\"data\") ## Error in `mutate()`: ## ℹ In argument: `data = purrr::map(labo, get_docs_lab)`. ## ℹ In group 8: `labo = \"https://data.archives-ouvertes.fr/structure/145345\"`, ## `labo_label = \"Environnement Ville Société\"`. ## Caused by error in `purrr::map()`: ## ℹ In index: 1. ## Caused by error in `httr2::req_perform()` at glitter/R/send_sparql.R:113:3: ## ! HTTP 500 Internal Server Error. dim(docs_EVS) ## Error in eval(expr, envir, enclos): object 'docs_EVS' not found docs_EVS_show = docs_EVS %>% select(-labo) %>% filter(date >= 2020) %>% unique() %>% select(auteur, date, type, citation, citation) %>% ungroup() ## Error in select(., -labo): object 'docs_EVS' not found dim(docs_EVS_show) ## Error in eval(expr, envir, enclos): object 'docs_EVS_show' not found DT::datatable(docs_EVS_show) ## Error in crosstalk::is.SharedData(data): object 'docs_EVS_show' not found"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"rendus-graphiques","dir":"Articles","previous_headings":"","what":"Rendus graphiques","title":"glitter for HAL (en français)","text":"peut dès lors utiliser ces données pour produire un certain nombre de graphiques permettant d’apprécier la production du laboratoire au cours du temps: Il ne s’agit là que d’un exemple (parmi beaucoup d’autres possibilités comme l’exploitation de mots clés, de statistiques par journal, de réseaux d’auteurs) pour exploiter ces données. Nanmoins ces méthodes allant au-delà du “scope” du package glitter nous n’irons pas plus loin en terme d’analyse des résultats des requêtes dans ce document.","code":"docs_datecitation = docs_EVS %>% group_by(type) %>% mutate(ntype = n()) %>% ungroup() %>% mutate(ntot = n()) %>% mutate(proptype = ntype/ntot) %>% filter(proptype > 0.05) %>% group_by(date, citation, type) %>% summarise(n = n()) %>% filter(date > 2015) ## Error in group_by(., type): object 'docs_EVS' not found ggplot(docs_datecitation, aes(x = date, y = n, fill = type)) + geom_bar(stat = \"identity\") + facet_grid(rows = vars(type)) ## Error in ggplot(docs_datecitation, aes(x = date, y = n, fill = type)): object 'docs_datecitation' not found"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"find-items-and-properties-to-build-your-query","dir":"Articles","previous_headings":"","what":"Find items and properties to build your query","title":"glitter for Wikidata","text":"find identifiers items properties interest particular case study, can: browse Wikidata use package WikidataR (functions WikidataR::find_item(), WikidataR::find_property()). , explore second option Let’s try find Wikidata identifier Lyon metro network: ’d interested, instance, subway stations part network. Let’s try find property identifier corresponds notion: ’re looking stations part (“wdt:P16”) Lyon metro network (“wd:Q1552”).","code":"WikidataR::find_item(\"Metro Lyon\") #> #> Wikidata item search #> #> Number of results: 1 #> #> Results: #> 1 Lyon Metro (Q1552) - public transportation network in Lyon, France WikidataR::find_property(\"part of\") #> #> Wikidata property search #> #> Number of results: 10 #> #> Results: #> 1 part of (P361) - object of which the subject is a part (if this subject is already part of object A which is a part of object B, then please only make the subject part of object A), inverse property of \"has part\" (P527, see also \"has parts of the class\" (P2670)) #> 2 parent organization (P749) - parent organization of an organization, opposite of subsidiaries (P355) #> 3 published in (P1433) - larger work that a given work was published in, like a book, journal or music album #> 4 constellation (P59) - the area of the celestial sphere of which the subject is a part (from a scientific standpoint, not an astrological one) #> 5 on focus list of Wikimedia project (P5008) - property to indicate that an item is of particular interest for a Wikimedia project. This property does not add notability. Items should not be created with this property if they are not notable for Wikidata. See also P6104, P972, P2354. #> 6 part of the series (P179) - series which contains the subject #> 7 member of sports team (P54) - sports teams or clubs that the subject represents or represented #> 8 transport network (P16) - network the infrastructure is a part of #> 9 partially coincident with (P1382) - object that partially overlaps with the subject in its instances, parts, or members #> 10 diaspora (P3833) - diaspora that a cultural group belongs to"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"use-glitter-functions-to-start-exploring-data","dir":"Articles","previous_headings":"","what":"Use glitter functions to start exploring data","title":"glitter for Wikidata","text":"glitter functions might now used start exploring data. ’re looking items (“unknown” query , hence use “?”) part Lyon metro network: also get labels stations, can use spq_label():","code":"stations = spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_perform() head(stations) #> # A tibble: 6 × 1 #> items #> #> 1 http://www.wikidata.org/entity/Q2944 #> 2 http://www.wikidata.org/entity/Q2965 #> 3 http://www.wikidata.org/entity/Q2969 #> 4 http://www.wikidata.org/entity/Q2976 #> 5 http://www.wikidata.org/entity/Q5298 #> 6 http://www.wikidata.org/entity/Q599865 stations = spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_label(items) %>% spq_perform() head(stations) #> # A tibble: 6 × 2 #> items items_label #> #> 1 http://www.wikidata.org/entity/Q599865 Place Guichard - Bourse du Travail #> 2 http://www.wikidata.org/entity/Q613893 Hôtel de Ville - Louis Pradel #> 3 http://www.wikidata.org/entity/Q776088 Cordeliers #> 4 http://www.wikidata.org/entity/Q2944 Lyon Metro Line A #> 5 http://www.wikidata.org/entity/Q2965 Lyon Metro Line B #> 6 http://www.wikidata.org/entity/Q2969 Lyon Metro Line C"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"labelling","dir":"Articles","previous_headings":"Use glitter functions to start exploring data","what":"Labelling","title":"glitter for Wikidata","text":"query , spq_label(items), return table comprising items (Wikidata identifiers) items_label (human-readable label corresponding items). Wikidata unique identifier particularly useful, one can use argument .overwrite = TRUE labels returned, shorter name items:","code":"stations=spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_label(items, .overwrite = TRUE) %>% spq_perform() head(stations) #> # A tibble: 6 × 1 #> items #> #> 1 Place Guichard - Bourse du Travail #> 2 Hôtel de Ville - Louis Pradel #> 3 Cordeliers #> 4 Lyon Metro Line A #> 5 Lyon Metro Line B #> 6 Lyon Metro Line C"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"add-another-triple-pattern","dir":"Articles","previous_headings":"Detail query","what":"Add another triple pattern","title":"glitter for Wikidata","text":"turns , now get 48 items, actually correspond stations also types items metro lines. Let’s look item “Place Guichard - Bourse du Travail” (“wd:Q599865”) know correspond station. can e.g. Wikidata url associated item. Hence, property called “wdt:P31” (“instance ”) enable us collect specifically stations (“wd:Q928830”) instead part Lyon metro network.","code":"stations = spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% # added instruction spq_label(station, .overwrite = TRUE) %>% spq_perform() dim(stations) #> [1] 41 1 head(stations) #> # A tibble: 6 × 1 #> station #> #> 1 Place Guichard - Bourse du Travail #> 2 Hôtel de Ville - Louis Pradel #> 3 Cordeliers #> 4 Gare de Vénissieux #> 5 Stade de Gerland #> 6 Saxe - Gambetta"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"get-coordinates","dir":"Articles","previous_headings":"Detail query","what":"Get coordinates","title":"glitter for Wikidata","text":"want get geographical coordinate stations (property “wdt:P625”) can proceed way: tibble can transformed Simple feature collection (sfc) object using package sf: resulting object may used easily (instance) package leaflet:","code":"stations_coords = spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% spq_add(\"?station wdt:P625 ?coords\") %>% # added instruction spq_label(station, .overwrite = TRUE) %>% spq_perform() dim(stations_coords) #> [1] 41 2 head(stations_coords) #> # A tibble: 6 × 2 #> coords station #> #> 1 Point(4.847308333 45.759261111) Place Guichard - Bourse du Travail #> 2 Point(4.836022222 45.767377777) Hôtel de Ville - Louis Pradel #> 3 Point(4.835894444 45.763511111) Cordeliers #> 4 Point(4.88804 45.7058) Gare de Vénissieux #> 5 Point(4.83038 45.7272) Stade de Gerland #> 6 Point(4.8463 45.7543) Saxe - Gambetta stations_sf = st_as_sf(stations_coords, wkt = \"coords\") head(stations_sf) #> Simple feature collection with 6 features and 1 field #> Geometry type: POINT #> Dimension: XY #> Bounding box: xmin: 4.83038 ymin: 45.7058 xmax: 4.88804 ymax: 45.76738 #> CRS: NA #> # A tibble: 6 × 2 #> coords station #> #> 1 (4.847308 45.75926) Place Guichard - Bourse du Travail #> 2 (4.836022 45.76738) Hôtel de Ville - Louis Pradel #> 3 (4.835894 45.76351) Cordeliers #> 4 (4.88804 45.7058) Gare de Vénissieux #> 5 (4.83038 45.7272) Stade de Gerland #> 6 (4.8463 45.7543) Saxe - Gambetta leaflet(stations_sf) %>% addTiles() %>% addCircles(popup = ~station)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"add-property-qualifiers","dir":"Articles","previous_headings":"","what":"Add property qualifiers","title":"glitter for Wikidata","text":"Now, like view stations also connecting lines. One property particular interest prospect: P197, indicates stations one station connected . form connecting lines, information connection stations need complemented involved line direction connection. Hence, interested values property P197, also property qualifiers corresponding connecting line (P81) direction (P5051) can thus complete query way: Now, like put stations right order able form connecting lines. data-wrangling part bit tricky though directly due glitter-related operation. define function form_line() put rows table stations correct order. Now let’s apply function lines directions possible. Making full use tidyverse, can use iteratively function dropping table-like structure data using combination tidyr::nest() purrr::map(). use left_join() complete table ordering stations lines coordinates stations: stations_lines now sf points object properly formatted transformed sf lines object (stations right order line-direction, associated coordinates provided table): can now use new object display Lyon metro lines leaflet map:","code":"stations_adjacency=spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% spq_add(\"?station wdt:P625 ?coords\") %>% spq_add(\"?station p:P197 ?statement\") %>% # added instruction spq_add(\"?statement ps:P197 ?adjacent\") %>% # added instruction spq_add(\"?statement pq:P81 ?line\") %>% # added instruction spq_add(\"?statement pq:P5051 ?direction\") %>% # added instruction spq_label(\"station\", \"adjacent\", \"line\", \"direction\",.overwrite = TRUE) %>% spq_select(-statement) %>% spq_perform() %>% na.omit() %>% select(coords,station,adjacent,line,direction) head(stations_adjacency) #> # A tibble: 6 × 5 #> coords station adjacent line direction #> #> 1 Point(4.814544444 45.716669444) \"Gare d'Oullins\" \"\" Lyon… \"\" #> 2 Point(4.80535659 45.714273455) \"\" \"\" Lyon… \"\" #> 3 Point(4.836366666 45.770613888) \"Croix-Paquet\" \"Hôtel de Vi… Lyon… \"Hôtel d… #> 4 Point(4.83205 45.7748) \"Croix-Rousse\" \"Croix-Paque… Lyon… \"Hôtel d… #> 5 Point(4.83293 45.7855) \"Cuire\" \"Hénon\" Lyon… \"Hôtel d… #> 6 Point(4.8275 45.7795) \"Hénon\" \"Croix-Rouss… Lyon… \"Hôtel d… form_line = function(adjacencies, direction) { N = nrow(adjacencies) num = rep(NA,N) ind = which(adjacencies$adjacent == direction) i = N num[ind] = i while (i>1) { indnew = which(adjacencies$adjacent == adjacencies$station[ind]) ind = indnew i = i-1 num[ind] = i } adjacencies = adjacencies %>% mutate(num = num) %>% arrange(num) adjacencies = c(adjacencies$station, direction) return(adjacencies) } stations_lines = stations_adjacency %>% sf::st_drop_geometry() %>% # make this a regular tibble, not sf group_by(direction,line) %>% na.omit() %>% tidyr::nest(.key = \"adj\") %>% # have nested \"adj\" table for each direction-line mutate(station = purrr::map(.x = adj, .y = direction, ~form_line(.x,.y))) %>% tidyr::unnest(cols = \"station\") %>% ungroup() stations_lines=stations_lines %>% left_join(unique(stations_coords), # get corresponding coordinates by=c(\"station\")) %>% na.omit() head(stations_lines) #> # A tibble: 6 × 5 #> line direction adj station coords #> #> 1 Lyon Metro Line B \"\" \"\" Point… #> 2 Lyon Metro Line B \"\" \"\" Point… #> 3 Lyon Metro Line B \"\" \"Gare d'Oul… Point… #> 4 Lyon Metro Line B \"\" \"\" Point… #> 5 Lyon Metro Line B \"\" \"\" Point… #> 6 Lyon Metro Line C \"Hôtel de Ville - Louis Pradel\" \"Cuire\" Point… stations_lines_sf=stations_lines %>% sf::st_as_sf(wkt=\"coords\") %>% group_by(direction,line) %>% summarise(do_union = FALSE) %>% # for each group, and keeping order of points, sf::st_cast(\"LINESTRING\") # form a linestring geometry stations_lines_sf #> Simple feature collection with 9 features and 2 fields #> Geometry type: LINESTRING #> Dimension: XY #> Bounding box: xmin: 4.804185 ymin: 45.7016 xmax: 4.921998 ymax: 45.7855 #> CRS: NA #> # A tibble: 9 × 3 #> # Groups: direction [9] #> direction line coords #> #> 1 \"\" Lyon Metro Line B (4.805357 45.71427, 4.80418… #> 2 \"Charpennes - Charles Hernu\" Lyon Metro Line B (4.805357 45.71427, 4.80418… #> 3 \"Cuire\" Lyon Metro Line C (4.836022 45.76738, 4.83636… #> 4 \"Gare d'Oullins\" Lyon Metro Line B (4.863119 45.77054, 4.85943… #> 5 \"Gare de Vaise\" Lyon Metro Line D (4.88804 45.7058, 4.88759 4… #> 6 \"Gare de Vénissieux\" Lyon Metro Line D (4.80421 45.7794, 4.80549 4… #> 7 \"Hôtel de Ville - Louis Pradel\" Lyon Metro Line C (4.83293 45.7855, 4.8275 45… #> 8 \"Perrache\" Lyon Metro Line A (4.921998 45.76125, 4.90921… #> 9 \"Vaulx-en-Velin - La Soie\" Lyon Metro Line A (4.829182 45.75302, 4.83405… factpal <- colorFactor(topo.colors(8), unique(stations_lines$line)) leaflet(data=stations_sf) %>% addTiles() %>% addCircles(popup=~station) %>% addPolylines(data=stations_lines_sf, color=~factpal(line), popup=~line)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"explorer-les-données","dir":"Articles","previous_headings":"","what":"Explorer les données","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?s ?p ?o\") %>% spq_head(10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"dates-biographiques-dun-auteur","dir":"Articles","previous_headings":"","what":"Dates biographiques d’un auteur","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?auteur foaf:birthday ?jour\") %>% spq_add(\"?auteur bio:birth ?date1\") %>% spq_add(\"?auteur bio:death ?date2\") %>% spq_add(\"?auteur foaf:name ?nom\", .required = FALSE) %>% spq_arrange(jour) %>% spq_prefix() %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"toutes-les-éditions-de-loeuvre-les-fleurs-du-mal-de-baudelaire","dir":"Articles","previous_headings":"","what":"Toutes les éditions de l’oeuvre Les Fleurs du Mal de Baudelaire","title":"glitter for dataBNF","text":"","code":"fleurs_du_mal=\"\" tib=spq_init(endpoint = \"dataBNF\") %>% spq_add(\"{fleurs_du_mal} foaf:focus ?Oeuvre\") %>% spq_add(\"?edition rdarelationships:workManifested ?Oeuvre\") %>% spq_add(\"?edition dcterms:date ?date\", .required=FALSE) %>% spq_add(\"?edition dcterms:title ?titre\") %>% spq_add(\"?edition dcterms:publisher ?editeur\") %>% spq_head(n=10) %>% spq_prefix() %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"lien-à-un-document-numérisé-dans-galliga","dir":"Articles","previous_headings":"","what":"Lien à un document numérisé dans Galliga","title":"glitter for dataBNF","text":"","code":"doc=\"\" tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"{doc} rdarelationships:electronicReproduction ?URLGallica\") %>% spq_add(\"{doc} dcterms:title ?title\") %>% spq_prefix() %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"expositions-virtuelles-de-la-bnf","dir":"Articles","previous_headings":"","what":"Expositions virtuelles de la BNF","title":"glitter for dataBNF","text":"","code":"expo=\"\" tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?exposition a {expo}\") %>% spq_add(\"?exposition dcterms:title ?titre\") %>% spq_add(\"?exposition dcterms:subject ?sujet\") %>% spq_head(n=30) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"retrouver-un-nom-de-personne-à-partir-dun-isni","dir":"Articles","previous_headings":"","what":"Retrouver un nom de personne à partir d’un ISNI","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?person isni:identifierValid '0000000121012885'\") %>% spq_add(\"?person foaf:focus ?identity\") %>% spq_add(\"?identity foaf:familyName ?nom\") %>% spq_add(\"?identity foaf:givenName ?prenom\") %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"identifiant-ark-dune-notice-à-partir-du-numéro-frbnf","dir":"Articles","previous_headings":"","what":"Identifiant ARK d’une notice à partir du numéro FRBNF","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?pidArk bnf-onto:FRBNF '11992081'^^xsd:integer\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"retrouver-une-oeuvre-à-partir-dun-isbn","dir":"Articles","previous_headings":"","what":"Retrouver une oeuvre à partir d’un ISBN","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?work rdfs:label ?title\") %>% spq_add(\"?work dcterms:creator ?creator\") %>% spq_add(\"?manifestation bnf-onto:isbn '2-7028-4777-3'\") %>% spq_add(\"?manifestation rdarelationships:workManifested ?work\") %>% spq_add(\"?creator foaf:name ?name\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"tous-les-auteurs-morts-avant-1924","dir":"Articles","previous_headings":"","what":"Tous les auteurs morts avant 1924","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer('1924')) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(desc(as.integer(mort))) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"images-dans-data-bnf-fr","dir":"Articles","previous_headings":"","what":"Images dans data.bnf.fr","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?image dcterms:type \") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"ouvrages-adaptés-pour-la-jeunesse","dir":"Articles","previous_headings":"","what":"Ouvrages adaptés pour la jeunesse","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?manifestation bnf-onto:ouvrageJeunesse 'true'^^xsd:boolean\") %>% spq_add(\". rdarelationships:workManifested ?oeuvre\") %>% spq_add(\". rdfs:seeAlso ?uri\") %>% spq_group_by(uri, oeuvre) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"portraits-dauteur-issus-de-gallica","dir":"Articles","previous_headings":"","what":"Portraits d’auteur, issus de Gallica","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?auteur rdf:type skos:Concept\") %>% spq_add(\". foaf:focus ?person\") %>% spq_add(\"?doc rdarelationships:electronicReproduction ?url\") %>% spq_add(\". dcterms:subject ?auteur\") %>% spq_add(\". dcterms:subject \") %>% spq_head(n=10) %>% spq_group_by(auteur, url) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"termes-spécifiques-dun-sujet-rameau","dir":"Articles","previous_headings":"","what":"Termes spécifiques d’un sujet (RAMEAU)","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?sujet1 skos:prefLabel ?label\") %>% spq_add(\". skos:narrower ?uri2\") %>% spq_add(\"?uri2 skos:prefLabel ?label2\") %>% spq_add(\"?uri2 skos:narrower ?uri3\", .required = FALSE) %>% spq_add(\"?uri3 skos:prefLabel ?label3\", .required = FALSE) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"sujets-rameau-de-type-nom-commun","dir":"Articles","previous_headings":"","what":"Sujets RAMEAU de type nom commun","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?sujet dcterms:isPartOf \") %>% spq_add(\". skos:prefLabel ?label\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"alignement-entre-les-sujets-rameau-et-lieux","dir":"Articles","previous_headings":"","what":"Alignement entre les sujets RAMEAU et lieux","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?c a \") %>% spq_add(\"?lieu foaf:focus ?c\") %>% spq_add(\"?lieu skos:closeMatch ?concept\") %>% spq_group_by(lieu, concept , c) %>% spq_head(n=100) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"liens-vers-wikipedia-pour-les-auteurs","dir":"Articles","previous_headings":"","what":"Liens vers wikipedia pour les auteurs","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?ConceptA foaf:focus ?auteur\") %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?ConceptA rdfs:seeAlso ?wikipedia\") %>% spq_filter(str_detect(wikipedia,'wikipedia')) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"glitter-query-object","dir":"Articles","previous_headings":"","what":"glitter query object","title":"glitter design and internals","text":"query object list elements variables (vars), filters, etc. Later might make actual class, maybe R6 one? built different calls spq_ functions. SPARQL query string assembled spq_assemble(). Later might add linting stage.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"glitter-tooling","dir":"Articles","previous_headings":"","what":"glitter tooling","title":"glitter design and internals","text":"hood, glitter uses rlang package Lionel Henry Hadley Wickham encapsulate ... arguments quosures handling . Useful references Metaprogramming section Advanced R book Hadley Wickham well documentation rlang package. xmlparsedata package Gábor Csárdi parse R looking code, xml2 package Hadley Wickham, Jim Hester Jeroen Ooms, transform code SPARQL code XPath. Useful references documentation two packages well searching XPath query examples via search engine. httr2 package Hadley Wickham package perform queries. learnt sending queries thanks source code WikidataQueryServiceR package Mikhail Popov. details next sections.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"spq_add","dir":"Articles","previous_headings":"","what":"spq_add()","title":"glitter design and internals","text":"spq_add() works differently spq_ functions looks closer SPARQL. Clearly something like spq_add(query, \"?item wdt:P31 wd:Q13442814\") look like R code. motivation : easier copy-pasting SPARQL query examples; ability keep SPARQL concepts. Triple patterns parsed decompose_triples uses string manipulation. Now, one wants go full DSL, possible, via spq_filter() spq_mutate(). triple pattern spq_add(query, \"?item wdt:P31 wd:Q13442814\") means finding items instance (“wdt:P31”) scholarly article (“wd:Q13442814”). glitter, can also write looks like normal tidyverse pipeline. Note namespacing done R way .e. wdt::P31 opposed “wdt:P31”. Similary, adds variable “wdt:P1843” Sonchus oleraceus (“wd:Q331676”). can written:","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814)) spq_init() %>% spq_add(\"wd:Q331676 wdt:P1843 ?statement\") spq_init() %>% spq_mutate(statement = wdt::P1843(wd::Q331676))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"other-spq_-functions","dir":"Articles","previous_headings":"","what":"Other spq_ functions","title":"glitter design and internals","text":"spq_ functions spq_arrange(), spq_select(), spq_mutate(), spq_mutate() , spq_filter(), spq_summarize() core DSL. ... arguments three different things can passed: R-looking snippets (DSL), instance spq_filter(query, lang(itemTitle) == \"en\"); R-looking snippets string (programmatic use), instance spq_filter(query, 'lang(itemTitle) == \"en\"'); SPARQL snippets escaped spq() (copy-pasting SPARQL examples), instance spq_filter(query, spq('lang(?itemTitle)=\"en\"')). names arguments starts dot prevent name clashes. differentiate three things users can pass? First, arguments transformed quosures rlang::enquos(...). passed function like spq_treat_argument(). “Like” complex behavior spq_filter() spq_mutate(), can accept R-looking snippets translated either triple patterns , warrants bit logic. result class spq, means can use string , SPARQL. result another character, code translated (example: 'lang(itemTitle) == \"en\"'). , need get text expression via rlang::expr_text(arg) %>% stringr::str_replace(\"^~\", \"\") (example: user wrote lang(itemTitle) == \"en\"). two latter cases, R-looking code translate SPARQL snippet. first parse code xmlparsedata xml2. series transformations supported XPath happen. glitter package contains tibble called all_correspondences: instances n(blabla) become COUNT(blabla). also transform argument names. Look “SELECT” statement , str_c() function becomes GROUP_CONCAT() argument SEPARATOR. Also note argument comes colon, comma like R. Later, need document correspondences better, need stress test DSL cases using arguments.","code":"head(glitter::all_correspondences) #> # A tibble: 6 × 3 #> R SPARQL args #> #> 1 n COUNT #> 2 sum SUM #> 3 mean AVG #> 4 min MIN #> 5 max MAX #> 6 sample SAMPLE spq_init() %>% spq_summarise(authors = str_c(name, sep = ', '))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"special-case-of-spq_filter-and-spq_mutate","dir":"Articles","previous_headings":"Other spq_ functions","what":"Special case of spq_filter() and spq_mutate()","title":"glitter design and internals","text":"spq_filter() receives R-looking fragments translated SPARQL snippets FILTER… triple patterns. spq_mutate() receives R-looking fragments translated SPARQL snippets SELECT… triple patterns. moment detection based ::: R-looking fragment contains ::, assume become triple pattern. Later, need make robust function spq_set() makes easier create synonyms subject/verb/object via SPARQL VALUES. assume spq_filter()/spq_mutate() received R-looking fragment meant translated triple pattern, parsed , forgetting order two cases: spq_mutate(object = verb(subject)); spq_filter(subject == verb(object)).","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"r-cmd-check-hack","dir":"Articles","previous_headings":"","what":"R CMD check hack","title":"glitter design and internals","text":"examples using something like got flagged wdt dependency stated. understandable. bypass examples examples, R chunks section called “examples”. means aren’t checked. Thankfully similar code real tests!","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"future-work","dir":"Articles","previous_headings":"","what":"Future work","title":"glitter design and internals","text":"issue tracker glitter quite representative future work, well sentences starting “Later” article. stated beginning article, ideas comments welcome.","code":""},{"path":"https://lvaudor.github.io/glitter/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Lise Vaudor. Author, maintainer. Maëlle Salmon. Author.","code":""},{"path":"https://lvaudor.github.io/glitter/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Vaudor L, Salmon M (2023). glitter: glitter makes SPARQL. https://lvaudor.github.io/glitter/, https://github.com/lvaudor/glitter.","code":"@Manual{, title = {glitter: glitter makes SPARQL}, author = {Lise Vaudor and Maëlle Salmon}, year = {2023}, note = {https://lvaudor.github.io/glitter/, https://github.com/lvaudor/glitter}, }"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"glitter-","dir":"","previous_headings":"","what":"glitter makes SPARQL","title":"glitter makes SPARQL","text":"DSL SPARQL R. ✨ glitter produces sparkle SPARQL! ✨ package aims writing sending SPARQL queries without advanced knowledge SPARQL language syntax. makes exploration use Linked Open Data (Wikidata particular) easier know SPARQL well. glitter, compared writing SPARQL queries hand, code easier write, easier read peers know SPARQL. glitter package supports “domain-specific language” (DSL) function names (syntax) closer tidyverse base R SPARQL. instance, find corpus 5 articles title English “wikidata” title, instead writing SPARQL hand can run: Note able use str_detect() str_to_lower() (stringr package) instead SPARQL’s functions REGEX LCASE. perform query, get random subset movies date released, use Note able “overwrite” date variable, straightforward dplyr, much SPARQL.","code":"library(\"glitter\") query <- spq_init() %>% spq_add(\"?item wdt:P31 wd:Q13442814\") %>% spq_label(item) %>% spq_filter(str_detect(str_to_lower(item_label), 'wikidata')) %>% spq_head(n = 5) query #> PREFIX rdfs: #> SELECT ?item ?item_label #> WHERE { #> #> ?item wdt:P31 wd:Q13442814. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> BIND(COALESCE(?item_labell,'') AS #> ?item_label)FILTER(REGEX(LCASE(?item_label),\"wikidata\")) #> } #> #> LIMIT 5 spq_perform(query) #> # A tibble: 5 × 2 #> item item_label #> #> 1 http://www.wikidata.org/entity/Q18507561 Wikidata: A Free Collaborative Knowl… #> 2 http://www.wikidata.org/entity/Q21503276 Utilizing the Wikidata system to imp… #> 3 http://www.wikidata.org/entity/Q21503284 Wikidata: A platform for data integr… #> 4 http://www.wikidata.org/entity/Q23712646 Wikidata as a semantic framework for… #> 5 http://www.wikidata.org/entity/Q24074986 From Freebase to Wikidata: The Great… spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_label(film) %>% spq_add(\"?film wdt:P577 ?date\") %>% spq_mutate(date = year(date)) %>% spq_head(10) %>% spq_perform() #> # A tibble: 10 × 3 #> film date film_label #> #> 1 http://www.wikidata.org/entity/Q372 2009 We Live in Public #> 2 http://www.wikidata.org/entity/Q595 2011 The Intouchables #> 3 http://www.wikidata.org/entity/Q595 2011 The Intouchables #> 4 http://www.wikidata.org/entity/Q595 2012 The Intouchables #> 5 http://www.wikidata.org/entity/Q595 2012 The Intouchables #> 6 http://www.wikidata.org/entity/Q593 2011 A Gang Story #> 7 http://www.wikidata.org/entity/Q1365 1974 Swept Away #> 8 http://www.wikidata.org/entity/Q1365 1974 Swept Away #> 9 http://www.wikidata.org/entity/Q1365 1975 Swept Away #> 10 http://www.wikidata.org/entity/Q1365 1975 Swept Away"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"glitter makes SPARQL","text":"Install packages R-universe: GitHub:","code":"install.packages(\"glitter\", repos = \"https://lvaudor.r-universe.dev\") install.packages(\"remotes\") #if remotes is not already installed remotes::install_github(\"lvaudor/glitter\")"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"glitter makes SPARQL","text":"can access documentation regarding package glitter pkgdown website.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/glitter-package.html","id":null,"dir":"Reference","previous_headings":"","what":"glitter: glitter makes SPARQL — glitter-package","title":"glitter: glitter makes SPARQL — glitter-package","text":"package aims writing sending SPARQL queries. makes exploration use Linked Open Data (Wikidata particular) easier know SPARQL.","code":""},{"path":[]},{"path":"https://lvaudor.github.io/glitter/reference/glitter-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"glitter: glitter makes SPARQL — glitter-package","text":"Maintainer: Lise Vaudor lise.vaudor@ens-lyon.fr (ORCID) Authors: Maëlle Salmon msmaellesalmon@gmail.com (ORCID)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":null,"dir":"Reference","previous_headings":"","what":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"Correspondence R-DSL functions SPARQL functions/operators.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"","code":"set_functions term_functions misc_functions string_functions numeric_functions datetime_functions operators all_correspondences"},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"data frame. R R-DSL function SPARQL SPARQL function args list-column R vs SPARQL argument names object class tbl_df (inherits tbl, data.frame) 21 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 9 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 12 rows 3 columns. object class tbl_df (inherits tbl, data.frame) 4 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 7 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 6 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 66 rows 3 columns.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":null,"dir":"Reference","previous_headings":"","what":"SPARQL escaping. — spq","title":"SPARQL escaping. — spq","text":"Like dbplyr::spq().","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SPARQL escaping. — spq","text":"","code":"spq(...) is.spq(x) as.spq(x)"},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SPARQL escaping. — spq","text":"... Character vectors combined single SPARQL expression. x Object coerce","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a triple pattern statement to a query — spq_add","title":"Add a triple pattern statement to a query — spq_add","text":"Add triple pattern statement query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a triple pattern statement to a query — spq_add","text":"","code":"spq_add( .query = NULL, .triple_pattern = NULL, .subject = NULL, .verb = NULL, .object = NULL, .prefixes = NULL, .required = TRUE, .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA), .filter = NULL )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a triple pattern statement to a query — spq_add","text":".query query .triple_pattern triple pattern statement (replaces arguments subject verb object) .subject anonymous variable (instance, default, \"?subject\") item (instance \"wd:Q456\")) .verb property (instance \"wdt:P190\") .object anonymous variable (instance, default, \"?object\") item (instance \"wd:Q456\")) .prefixes Custom prefixes .required whether existence value triple required (defaults TRUE). set FALSE, triples query returned even particular triple missing) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query. .filter Filter triple. use .required=FALSE","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a triple pattern statement to a query — spq_add","text":"arguments .subject, .verb, .object useful programmatic usage, actually used within glitter code .","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a triple pattern statement to a query — spq_add","text":"","code":"# find the cities spq_init() %>% spq_add(\"?city wdt:P31/wdt:P279* wd:Q486972\") %>% spq_label(city) %>% spq_mutate(coords = wdt::P625(city), .within_distance=list(center=c(long=4.84,lat=45.76), radius=5)) %>% spq_perform() # find the individuals of the species spq_init() %>% spq_add(\"?mayor wdt:P31 ?species\") %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780')) %>% # who occupy the function spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 wd:Q30185\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":null,"dir":"Reference","previous_headings":"","what":"Arrange results by variable value — spq_arrange","title":"Arrange results by variable value — spq_arrange","text":"Arrange results variable value","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Arrange results by variable value — spq_arrange","text":"","code":"spq_arrange(.query, ..., .replace = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Arrange results by variable value — spq_arrange","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .replace whether replace pre-existing arranging","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Arrange results by variable value — spq_arrange","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Arrange results by variable value — spq_arrange","text":"","code":"# descending length, ascending item_label, \"R\" syntax spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length), item_label) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?item_label DESC(?length) #> LIMIT 50 # descending length, ascending item_label, \"R\" syntax with quotes e.g. for a loop variable = \"length\" spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(sprintf(\"desc(%s)\", variable), item_label) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?item_label DESC(?length) #> LIMIT 50 # descending length, ascending item_label, SPARQL syntax spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(spq(\"DESC(?length) ?item_label\")) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?item_label #> LIMIT 50 # descending xsd:integer(mort), R syntax spq_init() %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer(\"1924\")) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(desc(as.integer(mort))) #> PREFIX foaf: #> PREFIX bio: #> PREFIX dcterms: #> SELECT ?auteur ?mort ?nom ?oeuvre #> WHERE { #> #> ?oeuvre dcterms:creator ?auteur. #> ?auteur bio:death ?mort. #> ?auteur foaf:familyName ?nom. #> FILTER(xsd:integer(?mort) } #> GROUP BY ?auteur ?mort ?nom #> ORDER BY DESC(xsd:integer(?mort)) # descending as.integer(mort), SPARQL syntax spq_init() %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer(\"1924\")) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(spq(\"DESC(xsd:integer(?mort))\")) #> PREFIX foaf: #> PREFIX bio: #> PREFIX dcterms: #> SELECT ?auteur ?mort ?nom ?oeuvre #> WHERE { #> #> ?oeuvre dcterms:creator ?auteur. #> ?auteur bio:death ?mort. #> ?auteur foaf:familyName ?nom. #> FILTER(xsd:integer(?mort) } #> GROUP BY ?auteur ?mort ?nom #> ORDER BY DESC(xsd:integer(?mort)) # Usage of the .replace argument # .replace = FALSE (default) spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length)) %>% spq_arrange(location) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?location #> LIMIT 50 # .replace = TRUE spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length)) %>% spq_arrange(location, .replace = TRUE) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?location #> LIMIT 50 # Mixing syntaxes spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length), spq(\"?location\")) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?location #> LIMIT 50"},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":null,"dir":"Reference","previous_headings":"","what":"Assemble query parts into a proper SPARQL query — spq_assemble","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"Assemble query parts proper SPARQL query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"","code":"spq_assemble(.query, strict = TRUE)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":".query list elements query strict whether perform linting query, error case problem detected.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"","code":"spq_init() %>% spq_add(\"?city wdt:P31 wd:Q515\") %>% spq_label(city, .languages = \"fr$\") %>% spq_add(\"?city wdt:P1082 ?pop\") %>% spq_assemble() %>% cat() #> PREFIX rdfs: #> SELECT ?city (COALESCE(?city_labell,'') AS ?city_label) ?pop #> WHERE { #> #> ?city wdt:P31 wd:Q515. #> OPTIONAL { #> \t?city rdfs:label ?city_labell. #> \tFILTER(lang(?city_labell) IN ('fr')) #> } #> #> ?city wdt:P1082 ?pop. #> #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the request control object for spq_init() — spq_control_request","title":"Create the request control object for spq_init() — spq_control_request","text":"Create request control object spq_init()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the request control object for spq_init() — spq_control_request","text":"","code":"spq_control_request( user_agent = getOption(\"glitter.ua\", \"glitter R package (https://github.com/lvaudor/glitter)\"), max_tries = getOption(\"glitter.max_tries\", 3L), max_seconds = getOption(\"glitter.max_seconds\", 120L), timeout = getOption(\"glitter.timeout\", 1000L), request_type = c(\"url\", \"body-form\"), rate = NULL, realm = NULL )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the request control object for spq_init() — spq_control_request","text":"user_agent string indicating user agent send query. max_tries, max_seconds Cap maximal number attemps max_tries total elapsed time first request max_seconds. timeout maximum number seconds wait (httr2::req_timeout()). request_type string indicating query sent: URL (url, default, common) body form (body-form). rate Maximum rate, .e. maximum number requests per second. Usually easiest expressed fraction, number_of_requests / number_of_seconds, e.g. 15 requests per minute 15 / 60. realm unique identifier throttle pool. supplied, defaults hostname request.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the request control object for spq_init() — spq_control_request","text":"list used spq_init()'s request_control argument.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create the request control object for spq_init() — spq_control_request","text":"","code":"# Defaults spq_control_request() #> $user_agent #> [1] \"glitter R package (https://github.com/lvaudor/glitter)\" #> #> $max_tries #> [1] 3 #> #> $max_seconds #> [1] 120 #> #> $timeout #> [1] 1000 #> #> $request_type #> [1] \"url\" #> #> $rate #> NULL #> #> $realm #> NULL #> #> attr(,\"class\") #> [1] \"glitter_request_control\" # Tweaking values spq_control_request( user_agent = \"Jane Doe https://example.com\", max_tries = 1L, max_seconds = 10L, timeout = 10L, request_type = \"url\" ) #> $user_agent #> [1] \"Jane Doe https://example.com\" #> #> $max_tries #> [1] 1 #> #> $max_seconds #> [1] 10 #> #> $timeout #> [1] 10 #> #> $request_type #> [1] \"url\" #> #> $rate #> NULL #> #> $realm #> NULL #> #> attr(,\"class\") #> [1] \"glitter_request_control\""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the endpoint info object for spq_init() — spq_endpoint_info","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"Create endpoint info object spq_init()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"","code":"spq_endpoint_info(label_property = \"rdfs:prefLabel\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"label_property Property used endpoint labelling.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"list used spq_init()'s endpoint_info argument.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"","code":"spq_endpoint_info(label_property = \"skos:preflabel\") #> $label_property #> [1] \"skos:preflabel\" #> #> attr(,\"class\") #> [1] \"glitter_endpoint_info\""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":null,"dir":"Reference","previous_headings":"","what":"Filters results by adding conditions — spq_filter","title":"Filters results by adding conditions — spq_filter","text":"Filters results adding conditions","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filters results by adding conditions — spq_filter","text":"","code":"spq_filter( .query = NULL, ..., .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filters results by adding conditions — spq_filter","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filters results by adding conditions — spq_filter","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Filters results by adding conditions — spq_filter","text":"","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814)) # Lexemes in English that match an expression # here starting with \"pota\" query <- spq_init() |> spq_prefix(prefixes = c(dct = \"http://purl.org/dc/terms/\")) |> spq_add(spq('?lexemeId dct:language wd:Q1860')) |> spq_mutate(lemma = wikibase::lemma(lexemeId)) |> spq_filter(str_detect(lemma, '^pota.*')) |> spq_select(lexemeId, lemma)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Group the results by one or more variables — spq_group_by","title":"Group the results by one or more variables — spq_group_by","text":"Group results one variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group the results by one or more variables — spq_group_by","text":"","code":"spq_group_by(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group the results by one or more variables — spq_group_by","text":".query query ... Either R-DSL strings variable names","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Group the results by one or more variables — spq_group_by","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group the results by one or more variables — spq_group_by","text":"","code":"spq_init() %>% spq_add(\"?item wdt:P361 wd:Q297853\") %>% spq_add(\"?item wdt:P1082 ?folkm_ngd\") %>% spq_add(\"?area wdt:P31 wd:Q1907114\") %>% spq_label(area) %>% spq_add(\"?area wdt:P527 ?item\") %>% spq_group_by(area, area_label) %>% spq_summarise(total_folkm = sum(folkm_ngd)) #> PREFIX rdfs: #> SELECT ?area ?area_label (SUM(?folkm_ngd) AS ?total_folkm) #> WHERE { #> #> ?item wdt:P361 wd:Q297853. #> ?item wdt:P1082 ?folkm_ngd. #> ?area wdt:P31 wd:Q1907114. #> OPTIONAL { #> ?area rdfs:label ?area_labell. #> FILTER(lang(?area_labell) IN ('en')) #> } #> #> ?area wdt:P527 ?item. #> BIND(COALESCE(?area_labell,'') AS ?area_label) #> #> } #> GROUP BY ?area ?area_label #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":null,"dir":"Reference","previous_headings":"","what":"Return the first lines of results — spq_head","title":"Return the first lines of results — spq_head","text":"Return first lines results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return the first lines of results — spq_head","text":"","code":"spq_head(.query, n = 5)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return the first lines of results — spq_head","text":".query list elements query n maximum number lines return","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return the first lines of results — spq_head","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"subsetting","dir":"Reference","previous_headings":"","what":"Subsetting","title":"Return the first lines of results — spq_head","text":"spq_offset() spq_head() useful used spq_arrange() makes order results predictable.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return the first lines of results — spq_head","text":"","code":"# Return the default of 5 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head() #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 5 # Return 42 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(42) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42"},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a query object. — spq_init","title":"Initialize a query object. — spq_init","text":"Initialize query object.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a query object. — spq_init","text":"","code":"spq_init( endpoint = \"wikidata\", request_control = spq_control_request(user_agent = getOption(\"glitter.ua\", \"glitter R package (https://github.com/lvaudor/glitter)\"), max_tries = getOption(\"glitter.max_tries\", 3L), max_seconds = getOption(\"glitter.max_seconds\", 120L), timeout = getOption(\"glitter.timeout\", 1000L), request_type = c(\"url\", \"body-form\")), endpoint_info = spq_endpoint_info(label_property = \"rdfs:label\") )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a query object. — spq_init","text":"endpoint Endpoint, either name usual_endpoints, URL request_control object returned spq_control_request() endpoint_info use usual endpoint usual_endpoints! Information endpoint","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a query object. — spq_init","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"printing","dir":"Reference","previous_headings":"","what":"Printing","title":"Initialize a query object. — spq_init","text":"SPARQL queries shown using cli package, built-theme. can change using cli.user_theme option. use .emph keywords functions, .field variables, .pkg prefixes, .val strings, .url prefix URLs. can also turn cli behavior setting environment variable \"GLITTER.NOCLI\" non-empty string. glitter snapshot tests.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Label variables — spq_label","title":"Label variables — spq_label","text":"Label variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Label variables — spq_label","text":"","code":"spq_label( .query, ..., .required = FALSE, .languages = getOption(\"glitter.lang\", \"en$\"), .overwrite = FALSE )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Label variables — spq_label","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .required whether existence value triple required (defaults TRUE). set FALSE, triples query returned even particular triple missing) .languages Languages query labels. Use NULL removing restrictions language (defined ), \"*\" defined language. write \"en\" can get labels regional variants \"en-GB\". want results \"en\" , write \"en$\". .overwrite whether replace variables labels. spq_select(blop) means get blop blop_label. spq_select(blop, .overwrite = TRUE) means get label blop, \"original\" blop variable returned.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Label variables — spq_label","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Label variables — spq_label","text":"spq_label() uses property: associated usual endpoint see usual_endpoints property indicated spq_endpoint_info()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"example","dir":"Reference","previous_headings":"","what":"Example","title":"Label variables — spq_label","text":"","code":"spq_init() %>% spq_add(\"?mayor wdt:P31 ?species\") %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780')) %>% # who occupy the function spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 wd:Q30185\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_label(mayor, place, .languages = c(\"fr\", \"en\", \"de\")) %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":null,"dir":"Reference","previous_headings":"","what":"Get labels in a specified language (apply only to Wikidata) — spq_language","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"Get labels specified language (apply Wikidata)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"","code":"spq_language(.query = NULL, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":".query query language language labels provided (defaults \"en\" English). See complete list Wikimedia language codes . can also set language \"auto\" Wikidata SPARQL engine try detect language automatically. Specifying several languages return labels languages following priority specified (e.g. language=\"fr,en\", label returned preferentially French, , French label item, English).","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"","code":"spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_label(film, .languages = c(\"fr$\", \"en$\")) %>% spq_head(10) #> PREFIX rdfs: #> SELECT ?film (COALESCE(?film_labell,'') AS ?film_label) (lang(?film_labell) AS #> ?film_label_lang) #> WHERE { #> #> ?film wdt:P31 wd:Q11424. #> OPTIONAL { #> ?film rdfs:label ?film_labell. #> FILTER(lang(?film_labell) IN ('fr') || lang(?film_labell) IN ('en')) #> } #> #> #> } #> #> LIMIT 10"},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":null,"dir":"Reference","previous_headings":"","what":"Create and modify variables in the results — spq_mutate","title":"Create and modify variables in the results — spq_mutate","text":"Create modify variables results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create and modify variables in the results — spq_mutate","text":"","code":"spq_mutate( .query, ..., .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create and modify variables in the results — spq_mutate","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create and modify variables in the results — spq_mutate","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Create and modify variables in the results — spq_mutate","text":"","code":"# common name of a plant species in different languages # the triplet pattern \"wd:Q331676 wdt:P1843 ?statement\" creates the variable statement # hence our writing it in reverse within the spq_mutate() function spq_init() %>% spq_mutate(statement = wdt::P1843(wd::Q331676)) %>% spq_mutate(lang = lang(statement))"},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":null,"dir":"Reference","previous_headings":"","what":"Offset the first generated result — spq_offset","title":"Offset the first generated result — spq_offset","text":"Offset first generated result","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Offset the first generated result — spq_offset","text":"","code":"spq_offset(.query, n = 5)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Offset the first generated result — spq_offset","text":".query list elements query n maximum number lines return","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Offset the first generated result — spq_offset","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"subsetting","dir":"Reference","previous_headings":"","what":"Subsetting","title":"Offset the first generated result — spq_offset","text":"spq_offset() spq_head() useful used spq_arrange() makes order results predictable.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Offset the first generated result — spq_offset","text":"","code":"# Return 42 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(n=42) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42 # Return 42 items after the first 11 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(42) %>% spq_offset(11) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42OFFSET 11"},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":null,"dir":"Reference","previous_headings":"","what":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"Assemble query parts sparql query send endpoint get tibble result.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"","code":"spq_perform( .query, endpoint = lifecycle::deprecated(), user_agent = lifecycle::deprecated(), max_tries = lifecycle::deprecated(), max_seconds = lifecycle::deprecated(), timeout = lifecycle::deprecated(), request_type = lifecycle::deprecated(), dry_run = FALSE, replace_prefixes = FALSE )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":".query list elements query endpoint string url corresponding SPARQL endpoint. Defaults \"Wikidata\" user_agent string indicating user agent send query. max_tries, max_seconds Cap maximal number attemps max_tries total elapsed time first request max_seconds. timeout maximum number seconds wait (httr2::req_timeout()). request_type string indicating query sent: URL (url, default, common) body form (body-form). dry_run Boolean indicating whether return output httr2::req_dry_run() rather httr2::req_perform(). Useful debugging. replace_prefixes Boolean indicating whether replace used prefixes results table, instance making, instance \"http://www.wikidata.org/entity/\" \"wd:\".","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"request-control","dir":"Reference","previous_headings":"","what":"Request control","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"Control way query performed via control_request argument spq_init(). way can create basic spq object correct options corresponding SPARQL service using, use basis subsequent glitter pipelines.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"","code":"# \\dontrun{ spq_init() %>% spq_add(.subject=\"?city\",.verb=\"wdt:P31\",.object=\"wd:Q515\") %>% spq_add(.subject=\"?city\",.verb=\"wdt:P1082\",.object=\"?pop\") %>% spq_label(city) %>% spq_head(n=5) %>% spq_perform() #> # A tibble: 5 × 3 #> city pop city_label #> #> 1 http://www.wikidata.org/entity/Q1963 5345000 Khartoum #> 2 http://www.wikidata.org/entity/Q1960 4715000 Dar es Salaam #> 3 http://www.wikidata.org/entity/Q2028 257275 Verona #> 4 http://www.wikidata.org/entity/Q2044 380948 Florence #> 5 http://www.wikidata.org/entity/Q2055 25085 Whitehorse # }"},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":null,"dir":"Reference","previous_headings":"","what":"Add prefixes to the query — spq_prefix","title":"Add prefixes to the query — spq_prefix","text":"Add prefixes query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add prefixes to the query — spq_prefix","text":"","code":"spq_prefix(.query = NULL, auto = TRUE, prefixes = NULL)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add prefixes to the query — spq_prefix","text":".query list elements query auto whether use built-prefixes prefixes vector prefixes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add prefixes to the query — spq_prefix","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add prefixes to the query — spq_prefix","text":"","code":"spq_init() %>% spq_prefix(prefixes=c(dbo=\"http://dbpedia.org/ontology/\")) #> PREFIX dbo: #> SELECT * #> WHERE { #> #> #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":null,"dir":"Reference","previous_headings":"","what":"Select (and create) particular variables — spq_select","title":"Select (and create) particular variables — spq_select","text":"Select (create) particular variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select (and create) particular variables — spq_select","text":"","code":"spq_select(.query = NULL, ..., .spq_duplicate = NULL)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select (and create) particular variables — spq_select","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .spq_duplicate handle duplicates: keep (NULL), eliminate (distinct) reduce (reduced, advanced usage).","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select (and create) particular variables — spq_select","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select (and create) particular variables — spq_select","text":"","code":"query = spq_init() spq_select(query, count = n (human), eyecolor_label, haircolor_label) #> #> SELECT (COUNT(?human) AS ?count) ?eyecolor_label ?haircolor_label #> WHERE { #> #> #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Set helper values for the query — spq_set","title":"Set helper values for the query — spq_set","text":"Set helper values query (helps readability)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set helper values for the query — spq_set","text":"","code":"spq_set(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set helper values for the query — spq_set","text":".query query ... Helper values definition.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set helper values for the query — spq_set","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Set helper values for the query — spq_set","text":"","code":"# find the individuals of the species spq_init() %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780'), mayorcode = \"wd:Q30185\") %>% spq_filter(mayor == wdt::P31(species)) %>% spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 ?mayorcode\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_label(species, mayor, place) %>% spq_select(-species, -place, -node, -mayor, -mayorcode) %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarise each group of results to fewer results — spq_summarise","title":"Summarise each group of results to fewer results — spq_summarise","text":"Summarise group results fewer results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarise each group of results to fewer results — spq_summarise","text":"","code":"spq_summarise(.query, ...) spq_summarize(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarise each group of results to fewer results — spq_summarise","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarise each group of results to fewer results — spq_summarise","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarise each group of results to fewer results — spq_summarise","text":"","code":"result = spq_init() %>% spq_add(\"?item wdt:P361 wd:Q297853\") %>% spq_add(\"?item wdt:P1082 ?folkm_ngd\") %>% spq_add(\"?area wdt:P31 wd:Q1907114\") %>% spq_label(area) %>% spq_add(\"?area wdt:P527 ?item\") %>% spq_group_by(area, area_label) %>% spq_summarise(total_folkm = sum(folkm_ngd))"},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the observations — spq_tally","title":"Count the observations — spq_tally","text":"functions inspired dplyr::count() dplyr::tally(). spq_tally() assumes already done grouping.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the observations — spq_tally","text":"","code":"spq_tally(.query, sort = FALSE, name = \"n\") spq_count(.query, ..., sort = FALSE, name = \"n\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the observations — spq_tally","text":".query list elements query sort TRUE, show largest groups top. (like sort argument dplyr::tally()) name Name count column (like name argument dplyr::tally()) ... variables arrange (SPARQL strings escaped spq(), strings, see examples)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the observations — spq_tally","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the observations — spq_tally","text":"","code":"# \\dontrun{ spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(narrative_location) %>% spq_tally(name = \"n_films\") %>% spq_perform() #> # A tibble: 1 × 1 #> n_films #> #> 1 51165 # the same with spq_count spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(narrative_location) %>% spq_count(name = \"n_films\") %>% spq_perform() #> # A tibble: 1 × 1 #> n_films #> #> 1 51165 # Now with grouping spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(film, narrative_location) %>% spq_group_by(narrative_location_label) %>% spq_tally(sort = TRUE, name = \"n_films\") %>% spq_perform() #> # A tibble: 2,747 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,737 more rows # More direct with spq_count() spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(film, narrative_location) %>% spq_count(narrative_location_label, sort = TRUE, name = \"n_films\") %>% spq_perform() #> # A tibble: 2,747 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,737 more rows # }"},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":null,"dir":"Reference","previous_headings":"","what":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"Usual endpoints: dataset allows user refer using simplified name rather full url.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"","code":"usual_endpoints"},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"data frame usual SPARQL endpoints abbreviated names name abbreviated name SPARQL endpoint url full address SPARQL endpoint label_property property used labelling","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":null,"dir":"Reference","previous_headings":"","what":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"Usual prefixes: dataset allows user refer usual prefixes queries without manually specifying associated urls.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"","code":"usual_prefixes"},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"data frame usual prefixes type type prefix name prefix url corresponding ontology","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":null,"dir":"Reference","previous_headings":"","what":"Wikidata properties — wd_properties","title":"Wikidata properties — wd_properties","text":"Wikidata properties","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wikidata properties — wd_properties","text":"","code":"wd_properties"},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Wikidata properties — wd_properties","text":"data frame 8939 rows 5 variables: id id type property type label property label description property description altLabel alternative labels","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Wikidata properties — wd_properties","text":"Wikidata https://query.wikidata.org/#SELECT%20%3Fproperty%20%3FpropertyType%20%3FpropertyLabel%20%3FpropertyDescription%20%3FpropertyAltLabel%0AWHERE%20%7B%0A%20%20%3Fproperty%20wikibase%3ApropertyType%20%3FpropertyType.%0A%20%20SERVICE%20wikibase%3Alabel%20%7Bbd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0AORDER%20BY%20ASC%20%28xsd%3Ainteger%28STRAFTER%28STR%28%3Fproperty%29%2C%20%27P%27%29%29%29","code":""}] +[{"path":[]},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement lise.vaudor@ens-lyon.fr. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://lvaudor.github.io/glitter/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"a-word-of-caution","dir":"Articles","previous_headings":"","what":"A word of caution","title":"How to explore a new database with glitter","text":"Depending dataset (triplestore, context) ’re working , queries might just ask much service proceed caution. doubt, add spq_head() query pipeline, ask less time, use spq_count() get sense many results total.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"asking-for-a-subset-of-all-triples","dir":"Articles","previous_headings":"","what":"Asking for a subset of all triples","title":"How to explore a new database with glitter","text":"code ’ll ask 10 triples. Note use endpoint argument spq_init() indicate send query, well request_type argument. can one know whether service needs request_type = \"body-form\"? docs might mention . Trial error. LINDAS’ case run request via https://lindas.admin.ch/sparql/ use browser’s web developer console request tab, can see request sends query body. first query helpful shows can query! results however can … less helpful.","code":"library(\"glitter\") query_basis = spq_init( endpoint = \"https://ld.admin.ch/query\", request_control = spq_control_request( request_type = \"body-form\" ) ) query_basis %>% spq_add(\"?s ?p ?o\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"find-which-classes-are-declared","dir":"Articles","previous_headings":"Classes","what":"Find which classes are declared","title":"How to explore a new database with glitter","text":"classes occurring database provide information kind data find . can varied (across triplestores, even single triplestore) people, places, buildings, trees, even things abstract like concepts, philosophical currents, historical periods, etc. point might think need use prefixes query. prefixes present glitter::usual_prefixes, don’t need anything. ’re , use glitter::spq_prefix(). many classes defined total? query might big service. 1195 classes declared triplestore. many get one query, definitely many show ! Let us examine classes: now still dark service provides.","code":"query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable() nclasses = query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_count() %>% spq_perform() nclasses #> # A tibble: 1 × 1 #> n #> #> 1 1195 query_basis %>% spq_add(\"?class a rdfs:Class\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-classes-have-instances","dir":"Articles","previous_headings":"Classes","what":"Which classes have instances?","title":"How to explore a new database with glitter","text":"class might declared although even items fall . Getting classes instances actually corresponds another triple pattern, “?item instance ?class”, .k.. “?item ?class”:","code":"query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(- instance) %>% spq_arrange(class) %>% spq_head(n = 10) %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-classes-have-the-most-instances","dir":"Articles","previous_headings":"Classes","what":"Which classes have the most instances?","title":"How to explore a new database with glitter","text":"number items falling class actually gives even better overview contents triplestore: case class names quite self explanatory use","code":"query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_count(class, sort = TRUE) %>% # count items falling under class spq_head(20) %>% spq_perform() %>% knitr::kable() query_basis %>% spq_add(\"?instance a ?class\") %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_label(class) %>% # label class to get class_label spq_count(class, class_label, sort = TRUE) %>% # group by class and class_label to count spq_head(20) %>% spq_perform() %>% knitr::kable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"find-which-properties-are-declared","dir":"Articles","previous_headings":"Properties","what":"Find which properties are declared","title":"How to explore a new database with glitter","text":"Note instead use spq_add(\"?property rdfs:Property\") case returned nothing. many properties defined total? query might big service.","code":"query_basis %>% spq_add(\"?property a owl:DatatypeProperty\") %>% spq_head(n = 10) %>% spq_perform() %>% knitr::kable() query_basis %>% spq_add(\"?property a owl:DatatypeProperty\") %>% spq_count() %>% spq_perform() #> # A tibble: 1 × 1 #> n #> #> 1 241"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-properties-are-used","dir":"Articles","previous_headings":"Properties","what":"What properties are used?","title":"How to explore a new database with glitter","text":"Similarly counting instances classes, wish get sense properties actually used triplestore.","code":"query_basis %>% spq_add(\"?s ?property ?o\") %>% spq_select(- s, - o) %>% spq_select(property, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-values-does-a-given-property-have","dir":"Articles","previous_headings":"Properties","what":"What values does a given property have?","title":"How to explore a new database with glitter","text":"","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\"))%>% spq_add(\"?s schema:addressRegion ?value\") %>% spq_count(value, sort = TRUE) %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-class-use-a-particular-property","dir":"Articles","previous_headings":"","what":"Which class use a particular property?","title":"How to explore a new database with glitter","text":"One properties https://gont.ch/longName. class uses ?","code":"query_basis %>% spq_prefix(prefixes = c(\"gont\" = \"https://gont.ch/\")) %>% spq_add(\"?s gont:longName ?o\") %>% spq_add(\"?s a ?class\") %>% spq_select(-o, -s) %>% spq_select(class, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"what-data-is-stored-about-a-classs-instances","dir":"Articles","previous_headings":"","what":"What data is stored about a class’s instances?","title":"How to explore a new database with glitter","text":"items falling given class likely subject (object) common set properties. One might wish explore properties actually associated class. instance, LINDAS, properties schema:Organization class associated ? properties schema:PostalAddress class associated ?","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:Organization\") %>% spq_add(\"?s ?property ?value\") %>% spq_select(-value, -s, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable() query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:PostalAddress\") %>% spq_add(\"?s ?property ?value\") %>% spq_select(-value, -s, .spq_duplicate = \"distinct\") %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"which-data-or-property-name-includes-a-certain-substring","dir":"Articles","previous_headings":"","what":"Which data or property name includes a certain substring?","title":"How to explore a new database with glitter","text":"Let us examine whether exists LINDAS data related water, search string “hydro” “Hydro” :","code":"query_basis %>% spq_add(\"?s ?p ?o\") %>% spq_filter(str_detect(o, \"[Hh]ydro\")) %>% spq_select(-s, .spq_duplicate = \"distinct\") %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/explore.html","id":"an-example-query-based-on-what-we-now-know","dir":"Articles","previous_headings":"","what":"An example query based on what we now know","title":"How to explore a new database with glitter","text":"wrap , let us now use LINDAS triplestore actual data query: instance try collect organizations “swiss” name:","code":"query_basis %>% spq_prefix(prefixes = c(\"schema\" = \"http://schema.org/\")) %>% spq_add(\"?s a schema:Organization\") %>% spq_add(\"?s schema:name ?name\") %>% spq_filter(str_detect(name, \"swiss\")) %>% spq_head(10) %>% spq_perform() %>% knitr::kable()"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"requête-de-base","dir":"Articles","previous_headings":"","what":"Requête de base","title":"glitter for HAL (en français)","text":"Afin de ne pas trop en demander à HAL, créons une requête de base qui n’envoient pas trop de requêtes d’un coup.","code":"hal_basic_request <- spq_init( \"hal\", request_control = spq_control_request(rate = 3/60) )"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"entrée-par-auteurrice","dir":"Articles","previous_headings":"","what":"Entrée par auteur·rice","title":"glitter for HAL (en français)","text":"Essayons par exemple d’examiner s’il existe dans la base quelqu’un qui s’appelle (tout à fait au hasard) “Lise Vaudor”: plot chunk test_LV Il existe bien une personne ayant ce nom dans la base de données, qui fait l’objet d’une fiche consultable. La consultation de cette page montre que deux propriétés sont souvent renseignées: foaf:interest et foaf:topic_interest. Cette dernière propriété semble regrouper des mots-clés issus de l’ensemble des publications de l’auteur alors que foaf:interest correspond à des centres d’intérêt déclarés (probablement lors de la création du profil HAL: à vrai dire je ne m’en souviens plus!). Quoi qu’il en soit, l’information relative aux centres d’intérêt est accessible comme suit: plot chunk interet_LV plot chunk interet_LV_run","code":"test_LV = hal_basic_request %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% # récupère les personnes appelées \"Lise Vaudor\" spq_perform() DT::datatable(test_LV) requete = hal_basic_request %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?personne foaf:interest ?interet\") %>% # récupère les centres d'intérêt spq_label(interet, .languages = \"fr\") # étiquette les centres d'intérêt sequins::graph_query(requete, layout = \"tree\") interet_LV = requete %>% # garde seulement les étiquettes en français spq_perform() DT::datatable(interet_LV)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"documents-dune-auteurrice","dir":"Articles","previous_headings":"","what":"Documents d’un·e auteur·rice","title":"glitter for HAL (en français)","text":"Une des petites subtilités du modèle de données HAL consiste à considérer que un document un créateur·rice – ou auteur·rice – et un·e créateur·rice correspond à une personne.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"affiliations","dir":"Articles","previous_headings":"Documents d’un·e auteur·rice","what":"Affiliations","title":"glitter for HAL (en français)","text":"Par exemple, l’article “sampling influences statistical power detect changes abundance: application river restoration” pour créatrice (entre autres personnes) “Lise Vaudor à l’époque du Cemagref”, qui correspond à la personne “Lise Vaudor” qui elle est intemporelle 😉. Ainsi, c’est en considérant les créateurs de documents que l’va récupérer les affiliations: l’affiliation est une information qui se récupère en adoptant une entrée par document plutôt que par auteur·rice. plot chunk orga_LV_prep plot chunk orga_LV_run","code":"requete = hal_basic_request %>% spq_add(\"?doc dcterms:creator ?createur\") %>% # documents crées par créateur spq_add(\"?createur hal:structure ?affiliation\") %>% # créateur correspond à une affiliation spq_add(\"?createur hal:person ?personne\") %>% # créateur correspond à une personne spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_label(affiliation, .overwrite = TRUE, .languages = NULL) %>% # étiquette affiliation spq_group_by(affiliation) %>% # groupe par affiliation spq_summarise(n = n()) %>% spq_arrange(desc(n)) requete ## PREFIX foaf: ## PREFIX dcterms: ## PREFIX skos: ## PREFIX hal: ## SELECT ?affiliation (COUNT(*) AS ?n) ## WHERE { ## ## ?doc dcterms:creator ?createur. ## ?createur hal:structure ?affiliation0. ## ?createur hal:person ?personne. ## ?personne foaf:name 'Lise Vaudor'. ## OPTIONAL {?affiliation0 skos:prefLabel ?affiliation_labell.} ## BIND(COALESCE(?affiliation_labell,'') AS ?affiliation) ## ## } ## GROUP BY ?affiliation ## ORDER BY DESC(?n) sequins::graph_query(requete, layout=\"tree\") orga_LV = requete %>% # renvoie le nombre d'enregistrements spq_perform() DT::datatable(orga_LV)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"documents","dir":"Articles","previous_headings":"Documents d’un·e auteur·rice","what":"Documents","title":"glitter for HAL (en français)","text":"Si l’ne s’intéresse pas aux affiliations mais aux documents eux-mêmes: Cette requête renvoie une table comptant 106. Voici les 20 documents les plus récents: plot chunk docs_LV_recents","code":"docs_LV = hal_basic_request %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_add(\"?createur hal:structure ?affiliation\") %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_label(affiliation, .overwrite = TRUE, .languages = NULL) %>% spq_add(\"?doc dcterms:type ?type\") %>% spq_label(type, .languages = \"fr\") %>% spq_add(\"?doc dcterms:bibliographicCitation ?citation\") %>% spq_add(\"?doc dcterms:issued ?date\") %>% spq_mutate(date = str_sub(as.character(date), 1, 4)) %>% spq_group_by(citation, type_label, date) %>% spq_summarise(affiliation = str_c(affiliation, sep = \", \")) %>% spq_perform() docs_LV ## # A tibble: 106 × 4 ## citation date type_label affiliation ## ## 1 \"Lise Vaudor, E. Parrot, Hervé Piégay. Describi… 2013 Poster de… Plateforme… ## 2 \"Lise Vaudor, Sébastien Rey-Coyrehourcq, Fabien… 2018 Note de l… Environnem… ## 3 \"Lise Vaudor, Hervé Piégay, Vincent Wawrzyniak,… 2016 Communica… Environnem… ## 4 \"Véronique Benacchio, Hervé Piégay, Thomas Buff… 2017 Article d… Environnem… ## 5 \"V. Benacchio, Hervé Piégay, Thomas Buffin-Bela… 2014 Communica… Environnem… ## 6 \"Thomas Buhler, Emeline Comby, Lise Vaudor, Thi… 2021 Article d… Environnem… ## 7 \"Matthieu Adam, Marylise Cottet, Sylvie Morarde… 2020 Article d… Environnem… ## 8 \"Bastien Bonef, Lionel Gérard, Jean-Luc Rouvièr… 2015 Article d… Nanophysiq… ## 9 \"Hervé Piégay, Fanny Arnaud, Cassel Mathieu, Th… 2016 Article d… Environnem… ## 10 \"Jérémie Riquier, Hervé Piégay, Nicolas Lamouro… 2016 Communica… Environnem… ## # ℹ 96 more rows docs_LV %>% arrange(desc(date)) %>% head(20) %>% DT::datatable()"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"identification-du-laboratoire","dir":"Articles","previous_headings":"Entrée par laboratoire","what":"Identification du laboratoire","title":"glitter for HAL (en français)","text":"Intéressons-nous maintenant aux publications issues d’un laboratoire. Ici, nous avons choisi le laboratoire “Environnement Ville Société”, alias “EVS” ou encore “UMR 5600”. Essayons de le retrouver dans la base de données: Bon! Eh bien, étant donné la diversité des formats dans la dénomination d’EVS, un petit tri manuel s’impose. plot chunk labo_EVS_filter Créons maintenant une fonction qui permet de récupérer l’ensemble des documents pour chacune de ces dénominations de laboratoire. Appliquons maintenant cette fonction à chacune des dénominations possibles pour le labo EVS: Cette table compte de nombreux enregistrements. montre ci-dessous les plus récents (à partir de 2020):","code":"labo_EVS = hal_basic_request %>% spq_label(labo, .languages = NULL, .required = TRUE) %>% spq_add(\"?labo dcterms:identifier ?labo_id\", .required = FALSE) %>% spq_filter(str_detect(labo_label,\"EVS|(UMR 5600)|(Environnement Ville Soc)\")) %>% spq_perform() labo_EVS ## # A tibble: 21 × 3 ## labo labo_label labo_id ## ## 1 https://data.archives-ouvertes.fr/revue/36364 REVSTAT - Statist… ## 2 https://data.archives-ouvertes.fr/revue/115361 Issue 4 of SCS Tr… ## 3 https://data.archives-ouvertes.fr/structure/54063 GEVSM ## 4 https://data.archives-ouvertes.fr/structure/145345 Environnement Vil… UMR5600 ## 5 https://data.archives-ouvertes.fr/structure/390864 UMR 5600 EVS ## 6 https://data.archives-ouvertes.fr/structure/458855 Plateforme ISIG. … ## 7 https://data.archives-ouvertes.fr/structure/493368 Environnement Vil… ## 8 https://data.archives-ouvertes.fr/structure/516259 UMR CNRS 5600 EVS… ## 9 https://data.archives-ouvertes.fr/structure/516301 Environnement Vil… ## 10 https://data.archives-ouvertes.fr/structure/520344 EVS-LAURE UMR 56… ## # ℹ 11 more rows labo_EVS = labo_EVS %>% unique() %>% mutate(num = 1:n()) %>% filter(!(num %in% c(1,2,3,18))) %>% # ici je retire les labos qui ne correspondent pas à UMR 5600 / EVS select(-num) DT::datatable(labo_EVS) get_docs_lab = function(lab){ Sys.sleep(30) # extra-safe lab = paste0(\"<\",lab,\">\") result = hal_basic_request %>% spq_add(glue::glue(\"?createur hal:structure {lab}\")) %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name ?auteur\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_select(-createur) %>% spq_label(type, .languages = \"fr\") %>% # étiquette le type de document en français spq_add(\"?doc dcterms:bibliographicCitation ?citation\") %>% # récupère la citation spq_add(\"?doc dcterms:issued ?date\") %>% spq_perform() %>% mutate(date = stringr::str_sub(date,1,4)) %>% select(auteur, type = type_label, date, citation) return(result) } docs_EVS = labo_EVS %>% group_by(labo, labo_label) %>% tidyr::nest() %>% mutate(data = purrr::map(labo, get_docs_lab)) %>% tidyr::unnest(cols=\"data\") ## Error in `mutate()`: ## ℹ In argument: `data = purrr::map(labo, get_docs_lab)`. ## ℹ In group 8: `labo = \"https://data.archives-ouvertes.fr/structure/145345\"`, ## `labo_label = \"Environnement Ville Société\"`. ## Caused by error in `purrr::map()`: ## ℹ In index: 1. ## Caused by error in `httr2::req_perform()` at glitter/R/send_sparql.R:113:3: ## ! HTTP 500 Internal Server Error. dim(docs_EVS) ## Error in eval(expr, envir, enclos): object 'docs_EVS' not found docs_EVS_show = docs_EVS %>% select(-labo) %>% filter(date >= 2020) %>% unique() %>% select(auteur, date, type, citation, citation) %>% ungroup() ## Error in select(., -labo): object 'docs_EVS' not found dim(docs_EVS_show) ## Error in eval(expr, envir, enclos): object 'docs_EVS_show' not found DT::datatable(docs_EVS_show) ## Error in crosstalk::is.SharedData(data): object 'docs_EVS_show' not found"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_bibliometry.html","id":"rendus-graphiques","dir":"Articles","previous_headings":"","what":"Rendus graphiques","title":"glitter for HAL (en français)","text":"peut dès lors utiliser ces données pour produire un certain nombre de graphiques permettant d’apprécier la production du laboratoire au cours du temps: Il ne s’agit là que d’un exemple (parmi beaucoup d’autres possibilités comme l’exploitation de mots clés, de statistiques par journal, de réseaux d’auteurs) pour exploiter ces données. Nanmoins ces méthodes allant au-delà du “scope” du package glitter nous n’irons pas plus loin en terme d’analyse des résultats des requêtes dans ce document.","code":"docs_datecitation = docs_EVS %>% group_by(type) %>% mutate(ntype = n()) %>% ungroup() %>% mutate(ntot = n()) %>% mutate(proptype = ntype/ntot) %>% filter(proptype > 0.05) %>% group_by(date, citation, type) %>% summarise(n = n()) %>% filter(date > 2015) ## Error in group_by(., type): object 'docs_EVS' not found ggplot(docs_datecitation, aes(x = date, y = n, fill = type)) + geom_bar(stat = \"identity\") + facet_grid(rows = vars(type)) ## Error in ggplot(docs_datecitation, aes(x = date, y = n, fill = type)): object 'docs_datecitation' not found"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"find-items-and-properties-to-build-your-query","dir":"Articles","previous_headings":"","what":"Find items and properties to build your query","title":"glitter for Wikidata","text":"find identifiers items properties interest particular case study, can: browse Wikidata use package WikidataR (functions WikidataR::find_item(), WikidataR::find_property()). , explore second option Let’s try find Wikidata identifier Lyon metro network: ’d interested, instance, subway stations part network. Let’s try find property identifier corresponds notion: ’re looking stations part (“wdt:P16”) Lyon metro network (“wd:Q1552”).","code":"WikidataR::find_item(\"Metro Lyon\") #> #> Wikidata item search #> #> Number of results: 1 #> #> Results: #> 1 Lyon Metro (Q1552) - public transportation network in Lyon, France WikidataR::find_property(\"part of\") #> #> Wikidata property search #> #> Number of results: 10 #> #> Results: #> 1 part of (P361) - object of which the subject is a part (if this subject is already part of object A which is a part of object B, then please only make the subject part of object A), inverse property of \"has part\" (P527, see also \"has parts of the class\" (P2670)) #> 2 parent organization (P749) - parent organization of an organization, opposite of subsidiaries (P355) #> 3 published in (P1433) - larger work that a given work was published in, like a book, journal or music album #> 4 constellation (P59) - the area of the celestial sphere of which the subject is a part (from a scientific standpoint, not an astrological one) #> 5 on focus list of Wikimedia project (P5008) - property to indicate that an item is of particular interest for a Wikimedia project. This property does not add notability. Items should not be created with this property if they are not notable for Wikidata. See also P6104, P972, P2354. #> 6 part of the series (P179) - series which contains the subject #> 7 member of sports team (P54) - sports teams or clubs that the subject represents or represented #> 8 transport network (P16) - network the infrastructure is a part of #> 9 partially coincident with (P1382) - object that partially overlaps with the subject in its instances, parts, or members #> 10 diaspora (P3833) - diaspora that a cultural group belongs to"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"use-glitter-functions-to-start-exploring-data","dir":"Articles","previous_headings":"","what":"Use glitter functions to start exploring data","title":"glitter for Wikidata","text":"glitter functions might now used start exploring data. ’re looking items (“unknown” query , hence use “?”) part Lyon metro network: also get labels stations, can use spq_label():","code":"stations = spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_perform() head(stations) #> # A tibble: 6 × 1 #> items #> #> 1 http://www.wikidata.org/entity/Q2944 #> 2 http://www.wikidata.org/entity/Q2965 #> 3 http://www.wikidata.org/entity/Q2969 #> 4 http://www.wikidata.org/entity/Q2976 #> 5 http://www.wikidata.org/entity/Q5298 #> 6 http://www.wikidata.org/entity/Q599865 stations = spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_label(items) %>% spq_perform() head(stations) #> # A tibble: 6 × 2 #> items items_label #> #> 1 http://www.wikidata.org/entity/Q599865 Place Guichard - Bourse du Travail #> 2 http://www.wikidata.org/entity/Q613893 Hôtel de Ville - Louis Pradel #> 3 http://www.wikidata.org/entity/Q776088 Cordeliers #> 4 http://www.wikidata.org/entity/Q2944 Lyon Metro Line A #> 5 http://www.wikidata.org/entity/Q2965 Lyon Metro Line B #> 6 http://www.wikidata.org/entity/Q2969 Lyon Metro Line C"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"labelling","dir":"Articles","previous_headings":"Use glitter functions to start exploring data","what":"Labelling","title":"glitter for Wikidata","text":"query , spq_label(items), return table comprising items (Wikidata identifiers) items_label (human-readable label corresponding items). Wikidata unique identifier particularly useful, one can use argument .overwrite = TRUE labels returned, shorter name items:","code":"stations=spq_init() %>% spq_add(\"?items wdt:P16 wd:Q1552\") %>% spq_label(items, .overwrite = TRUE) %>% spq_perform() head(stations) #> # A tibble: 6 × 1 #> items #> #> 1 Place Guichard - Bourse du Travail #> 2 Hôtel de Ville - Louis Pradel #> 3 Cordeliers #> 4 Lyon Metro Line A #> 5 Lyon Metro Line B #> 6 Lyon Metro Line C"},{"path":[]},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"add-another-triple-pattern","dir":"Articles","previous_headings":"Detail query","what":"Add another triple pattern","title":"glitter for Wikidata","text":"turns , now get 48 items, actually correspond stations also types items metro lines. Let’s look item “Place Guichard - Bourse du Travail” (“wd:Q599865”) know correspond station. can e.g. Wikidata url associated item. Hence, property called “wdt:P31” (“instance ”) enable us collect specifically stations (“wd:Q928830”) instead part Lyon metro network.","code":"stations = spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% # added instruction spq_label(station, .overwrite = TRUE) %>% spq_perform() dim(stations) #> [1] 41 1 head(stations) #> # A tibble: 6 × 1 #> station #> #> 1 Gare d'Oullins #> 2 Place Guichard - Bourse du Travail #> 3 Hôtel de Ville - Louis Pradel #> 4 Cordeliers #> 5 Gare de Vénissieux #> 6 Stade de Gerland"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"get-coordinates","dir":"Articles","previous_headings":"Detail query","what":"Get coordinates","title":"glitter for Wikidata","text":"want get geographical coordinate stations (property “wdt:P625”) can proceed way: tibble can transformed Simple feature collection (sfc) object using package sf: resulting object may used easily (instance) package leaflet:","code":"stations_coords = spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% spq_add(\"?station wdt:P625 ?coords\") %>% # added instruction spq_label(station, .overwrite = TRUE) %>% spq_perform() dim(stations_coords) #> [1] 41 2 head(stations_coords) #> # A tibble: 6 × 2 #> coords station #> #> 1 Point(4.814544444 45.716669444) Gare d'Oullins #> 2 Point(4.847308333 45.759261111) Place Guichard - Bourse du Travail #> 3 Point(4.836022222 45.767377777) Hôtel de Ville - Louis Pradel #> 4 Point(4.835894444 45.763511111) Cordeliers #> 5 Point(4.88804 45.7058) Gare de Vénissieux #> 6 Point(4.83038 45.7272) Stade de Gerland stations_sf = st_as_sf(stations_coords, wkt = \"coords\") head(stations_sf) #> Simple feature collection with 6 features and 1 field #> Geometry type: POINT #> Dimension: XY #> Bounding box: xmin: 4.814544 ymin: 45.7058 xmax: 4.88804 ymax: 45.76738 #> CRS: NA #> # A tibble: 6 × 2 #> coords station #> #> 1 (4.814544 45.71667) Gare d'Oullins #> 2 (4.847308 45.75926) Place Guichard - Bourse du Travail #> 3 (4.836022 45.76738) Hôtel de Ville - Louis Pradel #> 4 (4.835894 45.76351) Cordeliers #> 5 (4.88804 45.7058) Gare de Vénissieux #> 6 (4.83038 45.7272) Stade de Gerland leaflet(stations_sf) %>% addTiles() %>% addCircles(popup = ~station)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_Wikidata.html","id":"add-property-qualifiers","dir":"Articles","previous_headings":"","what":"Add property qualifiers","title":"glitter for Wikidata","text":"Now, like view stations also connecting lines. One property particular interest prospect: P197, indicates stations one station connected . form connecting lines, information connection stations need complemented involved line direction connection. Hence, interested values property P197, also property qualifiers corresponding connecting line (P81) direction (P5051) can thus complete query way: Now, like put stations right order able form connecting lines. data-wrangling part bit tricky though directly due glitter-related operation. define function form_line() put rows table stations correct order. Now let’s apply function lines directions possible. Making full use tidyverse, can use iteratively function dropping table-like structure data using combination tidyr::nest() purrr::map(). use left_join() complete table ordering stations lines coordinates stations: stations_lines now sf points object properly formatted transformed sf lines object (stations right order line-direction, associated coordinates provided table): can now use new object display Lyon metro lines leaflet map:","code":"stations_adjacency=spq_init() %>% spq_add(\"?station wdt:P16 wd:Q1552\") %>% spq_add(\"?station wdt:P31 wd:Q928830\") %>% spq_add(\"?station wdt:P625 ?coords\") %>% spq_add(\"?station p:P197 ?statement\") %>% # added instruction spq_add(\"?statement ps:P197 ?adjacent\") %>% # added instruction spq_add(\"?statement pq:P81 ?line\") %>% # added instruction spq_add(\"?statement pq:P5051 ?direction\") %>% # added instruction spq_label(\"station\", \"adjacent\", \"line\", \"direction\",.overwrite = TRUE) %>% spq_select(-statement) %>% spq_perform() %>% na.omit() %>% select(coords,station,adjacent,line,direction) head(stations_adjacency) #> # A tibble: 6 × 5 #> coords station adjacent line direction #> #> 1 Point(4.814544444 45.716669444) \"Gare d'Oullins\" \"\" Lyon… \"\" #> 2 Point(4.80535659 45.714273455) \"\" \"\" Lyon… \"\" #> 3 Point(4.836366666 45.770613888) \"Croix-Paquet\" \"Hôtel de Vi… Lyon… \"Hôtel d… #> 4 Point(4.83205 45.7748) \"Croix-Rousse\" \"Croix-Paque… Lyon… \"Hôtel d… #> 5 Point(4.83293 45.7855) \"Cuire\" \"Hénon\" Lyon… \"Hôtel d… #> 6 Point(4.8275 45.7795) \"Hénon\" \"Croix-Rouss… Lyon… \"Hôtel d… form_line = function(adjacencies, direction) { N = nrow(adjacencies) num = rep(NA,N) ind = which(adjacencies$adjacent == direction) i = N num[ind] = i while (i>1) { indnew = which(adjacencies$adjacent == adjacencies$station[ind]) ind = indnew i = i-1 num[ind] = i } adjacencies = adjacencies %>% mutate(num = num) %>% arrange(num) adjacencies = c(adjacencies$station, direction) return(adjacencies) } stations_lines = stations_adjacency %>% sf::st_drop_geometry() %>% # make this a regular tibble, not sf group_by(direction,line) %>% na.omit() %>% tidyr::nest(.key = \"adj\") %>% # have nested \"adj\" table for each direction-line mutate(station = purrr::map(.x = adj, .y = direction, ~form_line(.x,.y))) %>% tidyr::unnest(cols = \"station\") %>% ungroup() stations_lines=stations_lines %>% left_join(unique(stations_coords), # get corresponding coordinates by=c(\"station\")) %>% na.omit() head(stations_lines) #> # A tibble: 6 × 5 #> line direction adj station coords #> #> 1 Lyon Metro Line B \"\" \"\" Point… #> 2 Lyon Metro Line B \"\" \"\" Point… #> 3 Lyon Metro Line B \"\" \"Gare d'Oul… Point… #> 4 Lyon Metro Line B \"\" \"\" Point… #> 5 Lyon Metro Line B \"\" \"\" Point… #> 6 Lyon Metro Line C \"Hôtel de Ville - Louis Pradel\" \"Cuire\" Point… stations_lines_sf=stations_lines %>% sf::st_as_sf(wkt=\"coords\") %>% group_by(direction,line) %>% summarise(do_union = FALSE) %>% # for each group, and keeping order of points, sf::st_cast(\"LINESTRING\") # form a linestring geometry stations_lines_sf #> Simple feature collection with 9 features and 2 fields #> Geometry type: LINESTRING #> Dimension: XY #> Bounding box: xmin: 4.804185 ymin: 45.7016 xmax: 4.921998 ymax: 45.7855 #> CRS: NA #> # A tibble: 9 × 3 #> # Groups: direction [9] #> direction line coords #> #> 1 \"\" Lyon Metro Line B (4.805357 45.71427, 4.80418… #> 2 \"Charpennes - Charles Hernu\" Lyon Metro Line B (4.805357 45.71427, 4.80418… #> 3 \"Cuire\" Lyon Metro Line C (4.836022 45.76738, 4.83636… #> 4 \"Gare d'Oullins\" Lyon Metro Line B (4.863119 45.77054, 4.85943… #> 5 \"Gare de Vaise\" Lyon Metro Line D (4.88804 45.7058, 4.88759 4… #> 6 \"Gare de Vénissieux\" Lyon Metro Line D (4.80421 45.7794, 4.80549 4… #> 7 \"Hôtel de Ville - Louis Pradel\" Lyon Metro Line C (4.83293 45.7855, 4.8275 45… #> 8 \"Perrache\" Lyon Metro Line A (4.921998 45.76125, 4.90921… #> 9 \"Vaulx-en-Velin - La Soie\" Lyon Metro Line A (4.829182 45.75302, 4.83405… factpal <- colorFactor(topo.colors(8), unique(stations_lines$line)) leaflet(data=stations_sf) %>% addTiles() %>% addCircles(popup=~station) %>% addPolylines(data=stations_lines_sf, color=~factpal(line), popup=~line)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"explorer-les-données","dir":"Articles","previous_headings":"","what":"Explorer les données","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?s ?p ?o\") %>% spq_head(10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"dates-biographiques-dun-auteur","dir":"Articles","previous_headings":"","what":"Dates biographiques d’un auteur","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?auteur foaf:birthday ?jour\") %>% spq_add(\"?auteur bio:birth ?date1\") %>% spq_add(\"?auteur bio:death ?date2\") %>% spq_add(\"?auteur foaf:name ?nom\", .required = FALSE) %>% spq_arrange(jour) %>% spq_prefix() %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"toutes-les-éditions-de-loeuvre-les-fleurs-du-mal-de-baudelaire","dir":"Articles","previous_headings":"","what":"Toutes les éditions de l’oeuvre Les Fleurs du Mal de Baudelaire","title":"glitter for dataBNF","text":"","code":"fleurs_du_mal=\"\" tib=spq_init(endpoint = \"dataBNF\") %>% spq_add(\"{fleurs_du_mal} foaf:focus ?Oeuvre\") %>% spq_add(\"?edition rdarelationships:workManifested ?Oeuvre\") %>% spq_add(\"?edition dcterms:date ?date\", .required=FALSE) %>% spq_add(\"?edition dcterms:title ?titre\") %>% spq_add(\"?edition dcterms:publisher ?editeur\") %>% spq_head(n=10) %>% spq_prefix() %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"lien-à-un-document-numérisé-dans-galliga","dir":"Articles","previous_headings":"","what":"Lien à un document numérisé dans Galliga","title":"glitter for dataBNF","text":"","code":"doc=\"\" tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"{doc} rdarelationships:electronicReproduction ?URLGallica\") %>% spq_add(\"{doc} dcterms:title ?title\") %>% spq_prefix() %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"expositions-virtuelles-de-la-bnf","dir":"Articles","previous_headings":"","what":"Expositions virtuelles de la BNF","title":"glitter for dataBNF","text":"","code":"expo=\"\" tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?exposition a {expo}\") %>% spq_add(\"?exposition dcterms:title ?titre\") %>% spq_add(\"?exposition dcterms:subject ?sujet\") %>% spq_head(n=30) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"retrouver-un-nom-de-personne-à-partir-dun-isni","dir":"Articles","previous_headings":"","what":"Retrouver un nom de personne à partir d’un ISNI","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?person isni:identifierValid '0000000121012885'\") %>% spq_add(\"?person foaf:focus ?identity\") %>% spq_add(\"?identity foaf:familyName ?nom\") %>% spq_add(\"?identity foaf:givenName ?prenom\") %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"identifiant-ark-dune-notice-à-partir-du-numéro-frbnf","dir":"Articles","previous_headings":"","what":"Identifiant ARK d’une notice à partir du numéro FRBNF","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?pidArk bnf-onto:FRBNF '11992081'^^xsd:integer\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"retrouver-une-oeuvre-à-partir-dun-isbn","dir":"Articles","previous_headings":"","what":"Retrouver une oeuvre à partir d’un ISBN","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?work rdfs:label ?title\") %>% spq_add(\"?work dcterms:creator ?creator\") %>% spq_add(\"?manifestation bnf-onto:isbn '2-7028-4777-3'\") %>% spq_add(\"?manifestation rdarelationships:workManifested ?work\") %>% spq_add(\"?creator foaf:name ?name\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"tous-les-auteurs-morts-avant-1924","dir":"Articles","previous_headings":"","what":"Tous les auteurs morts avant 1924","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer('1924')) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(desc(as.integer(mort))) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"images-dans-data-bnf-fr","dir":"Articles","previous_headings":"","what":"Images dans data.bnf.fr","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?image dcterms:type \") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"ouvrages-adaptés-pour-la-jeunesse","dir":"Articles","previous_headings":"","what":"Ouvrages adaptés pour la jeunesse","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?manifestation bnf-onto:ouvrageJeunesse 'true'^^xsd:boolean\") %>% spq_add(\". rdarelationships:workManifested ?oeuvre\") %>% spq_add(\". rdfs:seeAlso ?uri\") %>% spq_group_by(uri, oeuvre) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"portraits-dauteur-issus-de-gallica","dir":"Articles","previous_headings":"","what":"Portraits d’auteur, issus de Gallica","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?auteur rdf:type skos:Concept\") %>% spq_add(\". foaf:focus ?person\") %>% spq_add(\"?doc rdarelationships:electronicReproduction ?url\") %>% spq_add(\". dcterms:subject ?auteur\") %>% spq_add(\". dcterms:subject \") %>% spq_head(n=10) %>% spq_group_by(auteur, url) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"termes-spécifiques-dun-sujet-rameau","dir":"Articles","previous_headings":"","what":"Termes spécifiques d’un sujet (RAMEAU)","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?sujet1 skos:prefLabel ?label\") %>% spq_add(\". skos:narrower ?uri2\") %>% spq_add(\"?uri2 skos:prefLabel ?label2\") %>% spq_add(\"?uri2 skos:narrower ?uri3\", .required = FALSE) %>% spq_add(\"?uri3 skos:prefLabel ?label3\", .required = FALSE) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"sujets-rameau-de-type-nom-commun","dir":"Articles","previous_headings":"","what":"Sujets RAMEAU de type nom commun","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?sujet dcterms:isPartOf \") %>% spq_add(\". skos:prefLabel ?label\") %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"alignement-entre-les-sujets-rameau-et-lieux","dir":"Articles","previous_headings":"","what":"Alignement entre les sujets RAMEAU et lieux","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?c a \") %>% spq_add(\"?lieu foaf:focus ?c\") %>% spq_add(\"?lieu skos:closeMatch ?concept\") %>% spq_group_by(lieu, concept , c) %>% spq_head(n=100) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/glitter_for_dataBNF.html","id":"liens-vers-wikipedia-pour-les-auteurs","dir":"Articles","previous_headings":"","what":"Liens vers wikipedia pour les auteurs","title":"glitter for dataBNF","text":"","code":"tib=spq_init(endpoint=\"dataBNF\") %>% spq_add(\"?ConceptA foaf:focus ?auteur\") %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?ConceptA rdfs:seeAlso ?wikipedia\") %>% spq_filter(str_detect(wikipedia,'wikipedia')) %>% spq_head(n=10) %>% spq_perform() knitr::kable(tib)"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"glitter-query-object","dir":"Articles","previous_headings":"","what":"glitter query object","title":"glitter design and internals","text":"query object list elements variables (vars), filters, etc. Later might make actual class, maybe R6 one? built different calls spq_ functions. SPARQL query string assembled spq_assemble(). Later might add linting stage.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"glitter-tooling","dir":"Articles","previous_headings":"","what":"glitter tooling","title":"glitter design and internals","text":"hood, glitter uses rlang package Lionel Henry Hadley Wickham encapsulate ... arguments quosures handling . Useful references Metaprogramming section Advanced R book Hadley Wickham well documentation rlang package. xmlparsedata package Gábor Csárdi parse R looking code, xml2 package Hadley Wickham, Jim Hester Jeroen Ooms, transform code SPARQL code XPath. Useful references documentation two packages well searching XPath query examples via search engine. httr2 package Hadley Wickham package perform queries. learnt sending queries thanks source code WikidataQueryServiceR package Mikhail Popov. details next sections.","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"spq_add","dir":"Articles","previous_headings":"","what":"spq_add()","title":"glitter design and internals","text":"spq_add() works differently spq_ functions looks closer SPARQL. Clearly something like spq_add(query, \"?item wdt:P31 wd:Q13442814\") look like R code. motivation : easier copy-pasting SPARQL query examples; ability keep SPARQL concepts. Triple patterns parsed decompose_triples uses string manipulation. Now, one wants go full DSL, possible, via spq_filter() spq_mutate(). triple pattern spq_add(query, \"?item wdt:P31 wd:Q13442814\") means finding items instance (“wdt:P31”) scholarly article (“wd:Q13442814”). glitter, can also write looks like normal tidyverse pipeline. Note namespacing done R way .e. wdt::P31 opposed “wdt:P31”. Similary, adds variable “wdt:P1843” Sonchus oleraceus (“wd:Q331676”). can written:","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814)) spq_init() %>% spq_add(\"wd:Q331676 wdt:P1843 ?statement\") spq_init() %>% spq_mutate(statement = wdt::P1843(wd::Q331676))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"other-spq_-functions","dir":"Articles","previous_headings":"","what":"Other spq_ functions","title":"glitter design and internals","text":"spq_ functions spq_arrange(), spq_select(), spq_mutate(), spq_mutate() , spq_filter(), spq_summarize() core DSL. ... arguments three different things can passed: R-looking snippets (DSL), instance spq_filter(query, lang(itemTitle) == \"en\"); R-looking snippets string (programmatic use), instance spq_filter(query, 'lang(itemTitle) == \"en\"'); SPARQL snippets escaped spq() (copy-pasting SPARQL examples), instance spq_filter(query, spq('lang(?itemTitle)=\"en\"')). names arguments starts dot prevent name clashes. differentiate three things users can pass? First, arguments transformed quosures rlang::enquos(...). passed function like spq_treat_argument(). “Like” complex behavior spq_filter() spq_mutate(), can accept R-looking snippets translated either triple patterns , warrants bit logic. result class spq, means can use string , SPARQL. result another character, code translated (example: 'lang(itemTitle) == \"en\"'). , need get text expression via rlang::expr_text(arg) %>% stringr::str_replace(\"^~\", \"\") (example: user wrote lang(itemTitle) == \"en\"). two latter cases, R-looking code translate SPARQL snippet. first parse code xmlparsedata xml2. series transformations supported XPath happen. glitter package contains tibble called all_correspondences: instances n(blabla) become COUNT(blabla). also transform argument names. Look “SELECT” statement , str_c() function becomes GROUP_CONCAT() argument SEPARATOR. Also note argument comes colon, comma like R. Later, need document correspondences better, need stress test DSL cases using arguments.","code":"head(glitter::all_correspondences) #> # A tibble: 6 × 3 #> R SPARQL args #> #> 1 n COUNT #> 2 sum SUM #> 3 mean AVG #> 4 min MIN #> 5 max MAX #> 6 sample SAMPLE spq_init() %>% spq_summarise(authors = str_c(name, sep = ', '))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"special-case-of-spq_filter-and-spq_mutate","dir":"Articles","previous_headings":"Other spq_ functions","what":"Special case of spq_filter() and spq_mutate()","title":"glitter design and internals","text":"spq_filter() receives R-looking fragments translated SPARQL snippets FILTER… triple patterns. spq_mutate() receives R-looking fragments translated SPARQL snippets SELECT… triple patterns. moment detection based ::: R-looking fragment contains ::, assume become triple pattern. Later, need make robust function spq_set() makes easier create synonyms subject/verb/object via SPARQL VALUES. assume spq_filter()/spq_mutate() received R-looking fragment meant translated triple pattern, parsed , forgetting order two cases: spq_mutate(object = verb(subject)); spq_filter(subject == verb(object)).","code":""},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"r-cmd-check-hack","dir":"Articles","previous_headings":"","what":"R CMD check hack","title":"glitter design and internals","text":"examples using something like got flagged wdt dependency stated. understandable. bypass examples examples, R chunks section called “examples”. means aren’t checked. Thankfully similar code real tests!","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814))"},{"path":"https://lvaudor.github.io/glitter/articles/internals.html","id":"future-work","dir":"Articles","previous_headings":"","what":"Future work","title":"glitter design and internals","text":"issue tracker glitter quite representative future work, well sentences starting “Later” article. stated beginning article, ideas comments welcome.","code":""},{"path":"https://lvaudor.github.io/glitter/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Lise Vaudor. Author, maintainer. Maëlle Salmon. Author.","code":""},{"path":"https://lvaudor.github.io/glitter/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Vaudor L, Salmon M (2023). glitter: glitter makes SPARQL. https://lvaudor.github.io/glitter/, https://github.com/lvaudor/glitter.","code":"@Manual{, title = {glitter: glitter makes SPARQL}, author = {Lise Vaudor and Maëlle Salmon}, year = {2023}, note = {https://lvaudor.github.io/glitter/, https://github.com/lvaudor/glitter}, }"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"glitter-","dir":"","previous_headings":"","what":"glitter makes SPARQL","title":"glitter makes SPARQL","text":"DSL SPARQL R. ✨ glitter produces sparkle SPARQL! ✨ package aims writing sending SPARQL queries without advanced knowledge SPARQL language syntax. makes exploration use Linked Open Data (Wikidata particular) easier know SPARQL well. glitter, compared writing SPARQL queries hand, code easier write, easier read peers know SPARQL. glitter package supports “domain-specific language” (DSL) function names (syntax) closer tidyverse base R SPARQL. instance, find corpus 5 articles title English “wikidata” title, instead writing SPARQL hand can run: Note able use str_detect() str_to_lower() (stringr package) instead SPARQL’s functions REGEX LCASE. perform query, get random subset movies date released, use Note able “overwrite” date variable, straightforward dplyr, much SPARQL.","code":"library(\"glitter\") query <- spq_init() %>% spq_add(\"?item wdt:P31 wd:Q13442814\") %>% spq_label(item) %>% spq_filter(str_detect(str_to_lower(item_label), 'wikidata')) %>% spq_head(n = 5) query #> PREFIX rdfs: #> SELECT ?item ?item_label #> WHERE { #> #> ?item wdt:P31 wd:Q13442814. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> BIND(COALESCE(?item_labell,'') AS #> ?item_label)FILTER(REGEX(LCASE(?item_label),\"wikidata\")) #> } #> #> LIMIT 5 spq_perform(query) #> # A tibble: 5 × 2 #> item item_label #> #> 1 http://www.wikidata.org/entity/Q18507561 Wikidata: A Free Collaborative Knowl… #> 2 http://www.wikidata.org/entity/Q21503276 Utilizing the Wikidata system to imp… #> 3 http://www.wikidata.org/entity/Q21503284 Wikidata: A platform for data integr… #> 4 http://www.wikidata.org/entity/Q23712646 Wikidata as a semantic framework for… #> 5 http://www.wikidata.org/entity/Q24074986 From Freebase to Wikidata: The Great… spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_label(film) %>% spq_add(\"?film wdt:P577 ?date\") %>% spq_mutate(date = year(date)) %>% spq_head(10) %>% spq_perform() #> # A tibble: 10 × 3 #> film date film_label #> #> 1 http://www.wikidata.org/entity/Q372 2009 We Live in Public #> 2 http://www.wikidata.org/entity/Q595 2011 The Intouchables #> 3 http://www.wikidata.org/entity/Q595 2011 The Intouchables #> 4 http://www.wikidata.org/entity/Q595 2012 The Intouchables #> 5 http://www.wikidata.org/entity/Q595 2012 The Intouchables #> 6 http://www.wikidata.org/entity/Q593 2011 A Gang Story #> 7 http://www.wikidata.org/entity/Q1365 1974 Swept Away #> 8 http://www.wikidata.org/entity/Q1365 1974 Swept Away #> 9 http://www.wikidata.org/entity/Q1365 1975 Swept Away #> 10 http://www.wikidata.org/entity/Q1365 1975 Swept Away"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"glitter makes SPARQL","text":"Install packages R-universe: GitHub:","code":"install.packages(\"glitter\", repos = \"https://lvaudor.r-universe.dev\") install.packages(\"remotes\") #if remotes is not already installed remotes::install_github(\"lvaudor/glitter\")"},{"path":"https://lvaudor.github.io/glitter/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"glitter makes SPARQL","text":"can access documentation regarding package glitter pkgdown website.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/glitter-package.html","id":null,"dir":"Reference","previous_headings":"","what":"glitter: glitter makes SPARQL — glitter-package","title":"glitter: glitter makes SPARQL — glitter-package","text":"package aims writing sending SPARQL queries. makes exploration use Linked Open Data (Wikidata particular) easier know SPARQL.","code":""},{"path":[]},{"path":"https://lvaudor.github.io/glitter/reference/glitter-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"glitter: glitter makes SPARQL — glitter-package","text":"Maintainer: Lise Vaudor lise.vaudor@ens-lyon.fr (ORCID) Authors: Maëlle Salmon msmaellesalmon@gmail.com (ORCID)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":null,"dir":"Reference","previous_headings":"","what":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"Correspondence R-DSL functions SPARQL functions/operators.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"","code":"set_functions term_functions misc_functions string_functions numeric_functions datetime_functions operators all_correspondences"},{"path":"https://lvaudor.github.io/glitter/reference/sparql-dsl.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Correspondence between R-DSL functions and SPARQL functions/operators. — set_functions","text":"data frame. R R-DSL function SPARQL SPARQL function args list-column R vs SPARQL argument names object class tbl_df (inherits tbl, data.frame) 21 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 9 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 12 rows 3 columns. object class tbl_df (inherits tbl, data.frame) 4 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 7 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 6 rows 2 columns. object class tbl_df (inherits tbl, data.frame) 66 rows 3 columns.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":null,"dir":"Reference","previous_headings":"","what":"SPARQL escaping. — spq","title":"SPARQL escaping. — spq","text":"Like dbplyr::spq().","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SPARQL escaping. — spq","text":"","code":"spq(...) is.spq(x) as.spq(x)"},{"path":"https://lvaudor.github.io/glitter/reference/spq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SPARQL escaping. — spq","text":"... Character vectors combined single SPARQL expression. x Object coerce","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a triple pattern statement to a query — spq_add","title":"Add a triple pattern statement to a query — spq_add","text":"Add triple pattern statement query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a triple pattern statement to a query — spq_add","text":"","code":"spq_add( .query = NULL, .triple_pattern = NULL, .subject = NULL, .verb = NULL, .object = NULL, .prefixes = NULL, .required = TRUE, .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA), .filter = NULL )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a triple pattern statement to a query — spq_add","text":".query query .triple_pattern triple pattern statement (replaces arguments subject verb object) .subject anonymous variable (instance, default, \"?subject\") item (instance \"wd:Q456\")) .verb property (instance \"wdt:P190\") .object anonymous variable (instance, default, \"?object\") item (instance \"wd:Q456\")) .prefixes Custom prefixes .required whether existence value triple required (defaults TRUE). set FALSE, triples query returned even particular triple missing) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query. .filter Filter triple. use .required=FALSE","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a triple pattern statement to a query — spq_add","text":"arguments .subject, .verb, .object useful programmatic usage, actually used within glitter code .","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_add.html","id":"examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a triple pattern statement to a query — spq_add","text":"","code":"# find the cities spq_init() %>% spq_add(\"?city wdt:P31/wdt:P279* wd:Q486972\") %>% spq_label(city) %>% spq_mutate(coords = wdt::P625(city), .within_distance=list(center=c(long=4.84,lat=45.76), radius=5)) %>% spq_perform() # find the individuals of the species spq_init() %>% spq_add(\"?mayor wdt:P31 ?species\") %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780')) %>% # who occupy the function spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 wd:Q30185\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":null,"dir":"Reference","previous_headings":"","what":"Arrange results by variable value — spq_arrange","title":"Arrange results by variable value — spq_arrange","text":"Arrange results variable value","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Arrange results by variable value — spq_arrange","text":"","code":"spq_arrange(.query, ..., .replace = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Arrange results by variable value — spq_arrange","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .replace whether replace pre-existing arranging","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Arrange results by variable value — spq_arrange","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_arrange.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Arrange results by variable value — spq_arrange","text":"","code":"# descending length, ascending item_label, \"R\" syntax spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length), item_label) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?item_label DESC(?length) #> LIMIT 50 # descending length, ascending item_label, \"R\" syntax with quotes e.g. for a loop variable = \"length\" spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(sprintf(\"desc(%s)\", variable), item_label) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?item_label DESC(?length) #> LIMIT 50 # descending length, ascending item_label, SPARQL syntax spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(spq(\"DESC(?length) ?item_label\")) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?item_label #> LIMIT 50 # descending xsd:integer(mort), R syntax spq_init() %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer(\"1924\")) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(desc(as.integer(mort))) #> PREFIX foaf: #> PREFIX bio: #> PREFIX dcterms: #> SELECT ?auteur ?mort ?nom ?oeuvre #> WHERE { #> #> ?oeuvre dcterms:creator ?auteur. #> ?auteur bio:death ?mort. #> ?auteur foaf:familyName ?nom. #> FILTER(xsd:integer(?mort) } #> GROUP BY ?auteur ?mort ?nom #> ORDER BY DESC(xsd:integer(?mort)) # descending as.integer(mort), SPARQL syntax spq_init() %>% spq_add(\"?oeuvre dcterms:creator ?auteur\") %>% spq_add(\"?auteur bio:death ?mort\") %>% spq_add(\"?auteur foaf:familyName ?nom\") %>% spq_filter(as.integer(mort) < as.integer(\"1924\")) %>% spq_group_by(auteur, nom, mort) %>% spq_arrange(spq(\"DESC(xsd:integer(?mort))\")) #> PREFIX foaf: #> PREFIX bio: #> PREFIX dcterms: #> SELECT ?auteur ?mort ?nom ?oeuvre #> WHERE { #> #> ?oeuvre dcterms:creator ?auteur. #> ?auteur bio:death ?mort. #> ?auteur foaf:familyName ?nom. #> FILTER(xsd:integer(?mort) } #> GROUP BY ?auteur ?mort ?nom #> ORDER BY DESC(xsd:integer(?mort)) # Usage of the .replace argument # .replace = FALSE (default) spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length)) %>% spq_arrange(location) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?location #> LIMIT 50 # .replace = TRUE spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length)) %>% spq_arrange(location, .replace = TRUE) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY ?location #> LIMIT 50 # Mixing syntaxes spq_init() %>% spq_add(\"?item wdt:P31/wdt:P279* wd:Q4022\") %>% spq_label(item) %>% spq_add(\"?item wdt:P2043 ?length\") %>% spq_add(\"?item wdt:P625 ?location\") %>% spq_arrange(desc(length), spq(\"?location\")) %>% spq_head(50) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?length ?location #> WHERE { #> #> ?item wdt:P31/wdt:P279* wd:Q4022. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P2043 ?length. #> ?item wdt:P625 ?location. #> #> } #> ORDER BY DESC(?length) ?location #> LIMIT 50"},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":null,"dir":"Reference","previous_headings":"","what":"Assemble query parts into a proper SPARQL query — spq_assemble","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"Assemble query parts proper SPARQL query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"","code":"spq_assemble(.query, strict = TRUE)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":".query list elements query strict whether perform linting query, error case problem detected.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_assemble.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assemble query parts into a proper SPARQL query — spq_assemble","text":"","code":"spq_init() %>% spq_add(\"?city wdt:P31 wd:Q515\") %>% spq_label(city, .languages = \"fr$\") %>% spq_add(\"?city wdt:P1082 ?pop\") %>% spq_assemble() %>% cat() #> PREFIX rdfs: #> SELECT ?city (COALESCE(?city_labell,'') AS ?city_label) ?pop #> WHERE { #> #> ?city wdt:P31 wd:Q515. #> OPTIONAL { #> \t?city rdfs:label ?city_labell. #> \tFILTER(lang(?city_labell) IN ('fr')) #> } #> #> ?city wdt:P1082 ?pop. #> #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the request control object for spq_init() — spq_control_request","title":"Create the request control object for spq_init() — spq_control_request","text":"Create request control object spq_init()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the request control object for spq_init() — spq_control_request","text":"","code":"spq_control_request( user_agent = getOption(\"glitter.ua\", \"glitter R package (https://github.com/lvaudor/glitter)\"), max_tries = getOption(\"glitter.max_tries\", 3L), max_seconds = getOption(\"glitter.max_seconds\", 120L), timeout = getOption(\"glitter.timeout\", 1000L), request_type = c(\"url\", \"body-form\"), rate = NULL, realm = NULL )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the request control object for spq_init() — spq_control_request","text":"user_agent string indicating user agent send query. max_tries, max_seconds Cap maximal number attemps max_tries total elapsed time first request max_seconds. timeout maximum number seconds wait (httr2::req_timeout()). request_type string indicating query sent: URL (url, default, common) body form (body-form). rate Maximum rate, .e. maximum number requests per second. Usually easiest expressed fraction, number_of_requests / number_of_seconds, e.g. 15 requests per minute 15 / 60. realm unique identifier throttle pool. supplied, defaults hostname request.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the request control object for spq_init() — spq_control_request","text":"list used spq_init()'s request_control argument.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_control_request.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create the request control object for spq_init() — spq_control_request","text":"","code":"# Defaults spq_control_request() #> $user_agent #> [1] \"glitter R package (https://github.com/lvaudor/glitter)\" #> #> $max_tries #> [1] 3 #> #> $max_seconds #> [1] 120 #> #> $timeout #> [1] 1000 #> #> $request_type #> [1] \"url\" #> #> $rate #> NULL #> #> $realm #> NULL #> #> attr(,\"class\") #> [1] \"glitter_request_control\" # Tweaking values spq_control_request( user_agent = \"Jane Doe https://example.com\", max_tries = 1L, max_seconds = 10L, timeout = 10L, request_type = \"url\" ) #> $user_agent #> [1] \"Jane Doe https://example.com\" #> #> $max_tries #> [1] 1 #> #> $max_seconds #> [1] 10 #> #> $timeout #> [1] 10 #> #> $request_type #> [1] \"url\" #> #> $rate #> NULL #> #> $realm #> NULL #> #> attr(,\"class\") #> [1] \"glitter_request_control\""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Create the endpoint info object for spq_init() — spq_endpoint_info","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"Create endpoint info object spq_init()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"","code":"spq_endpoint_info(label_property = \"rdfs:prefLabel\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"label_property Property used endpoint labelling.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"list used spq_init()'s endpoint_info argument.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_endpoint_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create the endpoint info object for spq_init() — spq_endpoint_info","text":"","code":"spq_endpoint_info(label_property = \"skos:preflabel\") #> $label_property #> [1] \"skos:preflabel\" #> #> attr(,\"class\") #> [1] \"glitter_endpoint_info\""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":null,"dir":"Reference","previous_headings":"","what":"Filters results by adding conditions — spq_filter","title":"Filters results by adding conditions — spq_filter","text":"Filters results adding conditions","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filters results by adding conditions — spq_filter","text":"","code":"spq_filter( .query = NULL, ..., .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filters results by adding conditions — spq_filter","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filters results by adding conditions — spq_filter","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_filter.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Filters results by adding conditions — spq_filter","text":"","code":"spq_init() %>% spq_filter(item == wdt::P31(wd::Q13442814)) # Lexemes in English that match an expression # here starting with \"pota\" query <- spq_init() |> spq_prefix(prefixes = c(dct = \"http://purl.org/dc/terms/\")) |> spq_add(spq('?lexemeId dct:language wd:Q1860')) |> spq_mutate(lemma = wikibase::lemma(lexemeId)) |> spq_filter(str_detect(lemma, '^pota.*')) |> spq_select(lexemeId, lemma)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Group the results by one or more variables — spq_group_by","title":"Group the results by one or more variables — spq_group_by","text":"Group results one variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Group the results by one or more variables — spq_group_by","text":"","code":"spq_group_by(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Group the results by one or more variables — spq_group_by","text":".query query ... Either R-DSL strings variable names","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Group the results by one or more variables — spq_group_by","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_group_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Group the results by one or more variables — spq_group_by","text":"","code":"spq_init() %>% spq_add(\"?item wdt:P361 wd:Q297853\") %>% spq_add(\"?item wdt:P1082 ?folkm_ngd\") %>% spq_add(\"?area wdt:P31 wd:Q1907114\") %>% spq_label(area) %>% spq_add(\"?area wdt:P527 ?item\") %>% spq_group_by(area, area_label) %>% spq_summarise(total_folkm = sum(folkm_ngd)) #> PREFIX rdfs: #> SELECT ?area ?area_label (SUM(?folkm_ngd) AS ?total_folkm) #> WHERE { #> #> ?item wdt:P361 wd:Q297853. #> ?item wdt:P1082 ?folkm_ngd. #> ?area wdt:P31 wd:Q1907114. #> OPTIONAL { #> ?area rdfs:label ?area_labell. #> FILTER(lang(?area_labell) IN ('en')) #> } #> #> ?area wdt:P527 ?item. #> BIND(COALESCE(?area_labell,'') AS ?area_label) #> #> } #> GROUP BY ?area ?area_label #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":null,"dir":"Reference","previous_headings":"","what":"Return the first lines of results — spq_head","title":"Return the first lines of results — spq_head","text":"Return first lines results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return the first lines of results — spq_head","text":"","code":"spq_head(.query, n = 5)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return the first lines of results — spq_head","text":".query list elements query n maximum number lines return","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return the first lines of results — spq_head","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"subsetting","dir":"Reference","previous_headings":"","what":"Subsetting","title":"Return the first lines of results — spq_head","text":"spq_offset() spq_head() useful used spq_arrange() makes order results predictable.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_head.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return the first lines of results — spq_head","text":"","code":"# Return the default of 5 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head() #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 5 # Return 42 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(42) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42"},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize a query object. — spq_init","title":"Initialize a query object. — spq_init","text":"Initialize query object.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize a query object. — spq_init","text":"","code":"spq_init( endpoint = \"wikidata\", request_control = spq_control_request(user_agent = getOption(\"glitter.ua\", \"glitter R package (https://github.com/lvaudor/glitter)\"), max_tries = getOption(\"glitter.max_tries\", 3L), max_seconds = getOption(\"glitter.max_seconds\", 120L), timeout = getOption(\"glitter.timeout\", 1000L), request_type = c(\"url\", \"body-form\")), endpoint_info = spq_endpoint_info(label_property = \"rdfs:label\") )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Initialize a query object. — spq_init","text":"endpoint Endpoint, either name usual_endpoints, URL request_control object returned spq_control_request() endpoint_info use usual endpoint usual_endpoints! Information endpoint","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize a query object. — spq_init","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_init.html","id":"printing","dir":"Reference","previous_headings":"","what":"Printing","title":"Initialize a query object. — spq_init","text":"SPARQL queries shown using cli package, built-theme. can change using cli.user_theme option. use .emph keywords functions, .field variables, .pkg prefixes, .val strings, .url prefix URLs. can also turn cli behavior setting environment variable \"GLITTER.NOCLI\" non-empty string. glitter snapshot tests.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Label variables — spq_label","title":"Label variables — spq_label","text":"Label variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Label variables — spq_label","text":"","code":"spq_label( .query, ..., .required = FALSE, .languages = getOption(\"glitter.lang\", \"en$\"), .overwrite = FALSE )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Label variables — spq_label","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .required whether existence value triple required (defaults TRUE). set FALSE, triples query returned even particular triple missing) .languages Languages query labels. Use NULL removing restrictions language (defined ), \"*\" defined language. write \"en\" can get labels regional variants \"en-GB\". want results \"en\" , write \"en$\". .overwrite whether replace variables labels. spq_select(blop) means get blop blop_label. spq_select(blop, .overwrite = TRUE) means get label blop, \"original\" blop variable returned.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Label variables — spq_label","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Label variables — spq_label","text":"spq_label() uses property: associated usual endpoint see usual_endpoints property indicated spq_endpoint_info()","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_label.html","id":"example","dir":"Reference","previous_headings":"","what":"Example","title":"Label variables — spq_label","text":"","code":"spq_init() %>% spq_add(\"?mayor wdt:P31 ?species\") %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780')) %>% # who occupy the function spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 wd:Q30185\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_label(mayor, place, .languages = c(\"fr\", \"en\", \"de\")) %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":null,"dir":"Reference","previous_headings":"","what":"Get labels in a specified language (apply only to Wikidata) — spq_language","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"Get labels specified language (apply Wikidata)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"","code":"spq_language(.query = NULL, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":".query query language language labels provided (defaults \"en\" English). See complete list Wikimedia language codes . can also set language \"auto\" Wikidata SPARQL engine try detect language automatically. Specifying several languages return labels languages following priority specified (e.g. language=\"fr,en\", label returned preferentially French, , French label item, English).","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_language.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get labels in a specified language (apply only to Wikidata) — spq_language","text":"","code":"spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_label(film, .languages = c(\"fr$\", \"en$\")) %>% spq_head(10) #> PREFIX rdfs: #> SELECT ?film (COALESCE(?film_labell,'') AS ?film_label) (lang(?film_labell) AS #> ?film_label_lang) #> WHERE { #> #> ?film wdt:P31 wd:Q11424. #> OPTIONAL { #> ?film rdfs:label ?film_labell. #> FILTER(lang(?film_labell) IN ('fr') || lang(?film_labell) IN ('en')) #> } #> #> #> } #> #> LIMIT 10"},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":null,"dir":"Reference","previous_headings":"","what":"Create and modify variables in the results — spq_mutate","title":"Create and modify variables in the results — spq_mutate","text":"Create modify variables results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create and modify variables in the results — spq_mutate","text":"","code":"spq_mutate( .query, ..., .label = NA, .within_box = c(NA, NA), .within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create and modify variables in the results — spq_mutate","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .label See spq_label(). .within_box provided, rectangular bounding box triple query. Provided list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...)) .within_distance provided, circular bounding box triple query. Provided list(center=c(long=...,lat=...), radius=...), radius kilometers. center can also provided variable (instance, \"?location\") center coordinates retrieved directly query.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create and modify variables in the results — spq_mutate","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_mutate.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Create and modify variables in the results — spq_mutate","text":"","code":"# common name of a plant species in different languages # the triplet pattern \"wd:Q331676 wdt:P1843 ?statement\" creates the variable statement # hence our writing it in reverse within the spq_mutate() function spq_init() %>% spq_mutate(statement = wdt::P1843(wd::Q331676)) %>% spq_mutate(lang = lang(statement))"},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":null,"dir":"Reference","previous_headings":"","what":"Offset the first generated result — spq_offset","title":"Offset the first generated result — spq_offset","text":"Offset first generated result","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Offset the first generated result — spq_offset","text":"","code":"spq_offset(.query, n = 5)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Offset the first generated result — spq_offset","text":".query list elements query n maximum number lines return","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Offset the first generated result — spq_offset","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"subsetting","dir":"Reference","previous_headings":"","what":"Subsetting","title":"Offset the first generated result — spq_offset","text":"spq_offset() spq_head() useful used spq_arrange() makes order results predictable.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_offset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Offset the first generated result — spq_offset","text":"","code":"# Return 42 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(n=42) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42 # Return 42 items after the first 11 items spq_init() %>% spq_add(\"?item wdt:P31 wd:Q5\") %>% spq_label(item) %>% spq_add(\"?item wdt:P19/wdt:P131* wd:Q60\") %>% spq_add(\"?item wikibase:sitelinks ?linkcount\") %>% spq_arrange(desc(linkcount)) %>% spq_head(42) %>% spq_offset(11) #> PREFIX rdfs: #> SELECT ?item (COALESCE(?item_labell,'') AS ?item_label) ?linkcount #> WHERE { #> #> ?item wdt:P31 wd:Q5. #> OPTIONAL { #> ?item rdfs:label ?item_labell. #> FILTER(lang(?item_labell) IN ('en')) #> } #> #> ?item wdt:P19/wdt:P131* wd:Q60. #> ?item wikibase:sitelinks ?linkcount. #> #> } #> ORDER BY DESC(?linkcount) #> LIMIT 42OFFSET 11"},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":null,"dir":"Reference","previous_headings":"","what":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"Assemble query parts sparql query send endpoint get tibble result.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"","code":"spq_perform( .query, endpoint = lifecycle::deprecated(), user_agent = lifecycle::deprecated(), max_tries = lifecycle::deprecated(), max_seconds = lifecycle::deprecated(), timeout = lifecycle::deprecated(), request_type = lifecycle::deprecated(), dry_run = FALSE, replace_prefixes = FALSE )"},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":".query list elements query endpoint string url corresponding SPARQL endpoint. Defaults \"Wikidata\" user_agent string indicating user agent send query. max_tries, max_seconds Cap maximal number attemps max_tries total elapsed time first request max_seconds. timeout maximum number seconds wait (httr2::req_timeout()). request_type string indicating query sent: URL (url, default, common) body form (body-form). dry_run Boolean indicating whether return output httr2::req_dry_run() rather httr2::req_perform(). Useful debugging. replace_prefixes Boolean indicating whether replace used prefixes results table, instance making, instance \"http://www.wikidata.org/entity/\" \"wd:\".","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"request-control","dir":"Reference","previous_headings":"","what":"Request control","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"Control way query performed via control_request argument spq_init(). way can create basic spq object correct options corresponding SPARQL service using, use basis subsequent glitter pipelines.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_perform.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result. — spq_perform","text":"","code":"# \\dontrun{ spq_init() %>% spq_add(.subject=\"?city\",.verb=\"wdt:P31\",.object=\"wd:Q515\") %>% spq_add(.subject=\"?city\",.verb=\"wdt:P1082\",.object=\"?pop\") %>% spq_label(city) %>% spq_head(n=5) %>% spq_perform() #> # A tibble: 5 × 3 #> city pop city_label #> #> 1 http://www.wikidata.org/entity/Q1963 5345000 Khartoum #> 2 http://www.wikidata.org/entity/Q1960 4715000 Dar es Salaam #> 3 http://www.wikidata.org/entity/Q2028 257275 Verona #> 4 http://www.wikidata.org/entity/Q2044 380948 Florence #> 5 http://www.wikidata.org/entity/Q2055 25085 Whitehorse # }"},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":null,"dir":"Reference","previous_headings":"","what":"Add prefixes to the query — spq_prefix","title":"Add prefixes to the query — spq_prefix","text":"Add prefixes query","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add prefixes to the query — spq_prefix","text":"","code":"spq_prefix(.query = NULL, auto = TRUE, prefixes = NULL)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add prefixes to the query — spq_prefix","text":".query list elements query auto whether use built-prefixes prefixes vector prefixes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add prefixes to the query — spq_prefix","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_prefix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add prefixes to the query — spq_prefix","text":"","code":"spq_init() %>% spq_prefix(prefixes=c(dbo=\"http://dbpedia.org/ontology/\")) #> PREFIX dbo: #> SELECT * #> WHERE { #> #> #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":null,"dir":"Reference","previous_headings":"","what":"Select (and create) particular variables — spq_select","title":"Select (and create) particular variables — spq_select","text":"Select (create) particular variables","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select (and create) particular variables — spq_select","text":"","code":"spq_select(.query = NULL, ..., .spq_duplicate = NULL)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select (and create) particular variables — spq_select","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples) .spq_duplicate handle duplicates: keep (NULL), eliminate (distinct) reduce (reduced, advanced usage).","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select (and create) particular variables — spq_select","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_select.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select (and create) particular variables — spq_select","text":"","code":"spq_init() |> spq_prefix(prefixes = c(dct = \"http://purl.org/dc/terms/\")) |> spq_add(spq('?lexemeId dct:language wd:Q1860')) |> spq_add(spq(\"?lexemeId wikibase:lemma ?lemma\")) |> spq_filter(str_detect(lemma, '^pota.*')) |> spq_select(- lemma) #> PREFIX dct: #> SELECT ?lexemeId #> WHERE { #> #> ?lexemeId dct:language wd:Q1860. #> ?lexemeId wikibase:lemma ?lemma. #> FILTER(REGEX(?lemma,\"^pota.*\")) #> } #> spq_init() |> spq_prefix(prefixes = c(dct = \"http://purl.org/dc/terms/\")) |> spq_add(spq('?lexemeId dct:language wd:Q1860')) |> spq_add(spq(\"?lexemeId wikibase:lemma ?lemma\")) |> spq_filter(str_detect(lemma, '^pota.*')) |> spq_select(lemma) #> PREFIX dct: #> SELECT ?lemma #> WHERE { #> #> ?lexemeId dct:language wd:Q1860. #> ?lexemeId wikibase:lemma ?lemma. #> FILTER(REGEX(?lemma,\"^pota.*\")) #> } #>"},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Set helper values for the query — spq_set","title":"Set helper values for the query — spq_set","text":"Set helper values query (helps readability)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set helper values for the query — spq_set","text":"","code":"spq_set(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set helper values for the query — spq_set","text":".query query ... Helper values definition.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set helper values for the query — spq_set","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_set.html","id":"some-examples","dir":"Reference","previous_headings":"","what":"Some examples","title":"Set helper values for the query — spq_set","text":"","code":"# find the individuals of the species spq_init() %>% # dog, cat or chicken spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780'), mayorcode = \"wd:Q30185\") %>% spq_filter(mayor == wdt::P31(species)) %>% spq_add(\"?mayor p:P39 ?node\") %>% # of mayor spq_add(\"?node ps:P39 ?mayorcode\") %>% # of some places spq_add(\"?node pq:P642 ?place\") %>% spq_label(species, mayor, place) %>% spq_select(-species, -place, -node, -mayor, -mayorcode) %>% spq_perform()"},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":null,"dir":"Reference","previous_headings":"","what":"Summarise each group of results to fewer results — spq_summarise","title":"Summarise each group of results to fewer results — spq_summarise","text":"Summarise group results fewer results","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Summarise each group of results to fewer results — spq_summarise","text":"","code":"spq_summarise(.query, ...) spq_summarize(.query, ...)"},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Summarise each group of results to fewer results — spq_summarise","text":".query list elements query ... variables arrange (SPARQL strings escaped spq(), strings, see examples)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Summarise each group of results to fewer results — spq_summarise","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_summarise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Summarise each group of results to fewer results — spq_summarise","text":"","code":"result = spq_init() %>% spq_add(\"?item wdt:P361 wd:Q297853\") %>% spq_add(\"?item wdt:P1082 ?folkm_ngd\") %>% spq_add(\"?area wdt:P31 wd:Q1907114\") %>% spq_label(area) %>% spq_add(\"?area wdt:P527 ?item\") %>% spq_group_by(area, area_label) %>% spq_summarise(total_folkm = sum(folkm_ngd))"},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":null,"dir":"Reference","previous_headings":"","what":"Count the observations — spq_tally","title":"Count the observations — spq_tally","text":"functions inspired dplyr::count() dplyr::tally(). spq_tally() assumes already done grouping.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count the observations — spq_tally","text":"","code":"spq_tally(.query, sort = FALSE, name = \"n\") spq_count(.query, ..., sort = FALSE, name = \"n\")"},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count the observations — spq_tally","text":".query list elements query sort TRUE, show largest groups top. (like sort argument dplyr::tally()) name Name count column (like name argument dplyr::tally()) ... variables arrange (SPARQL strings escaped spq(), strings, see examples)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count the observations — spq_tally","text":"query object","code":""},{"path":"https://lvaudor.github.io/glitter/reference/spq_tally.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count the observations — spq_tally","text":"","code":"# \\dontrun{ spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(narrative_location) %>% spq_tally(name = \"n_films\") %>% spq_perform() #> # A tibble: 1 × 1 #> n_films #> #> 1 51171 # the same with spq_count spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(narrative_location) %>% spq_count(name = \"n_films\") %>% spq_perform() #> # A tibble: 1 × 1 #> n_films #> #> 1 51171 # Now with grouping spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(film, narrative_location) %>% spq_group_by(narrative_location_label) %>% spq_tally(sort = TRUE, name = \"n_films\") %>% spq_perform() #> # A tibble: 2,750 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 #> 7 Rome 969 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,740 more rows # More direct with spq_count() spq_init() %>% spq_add(\"?film wdt:P31 wd:Q11424\") %>% spq_mutate(narrative_location = wdt::P840(film)) %>% spq_label(film, narrative_location) %>% spq_count(narrative_location_label, sort = TRUE, name = \"n_films\") %>% spq_perform() #> # A tibble: 2,750 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1494 #> 6 England 1427 #> 7 Rome 969 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,740 more rows # }"},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":null,"dir":"Reference","previous_headings":"","what":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"Usual endpoints: dataset allows user refer using simplified name rather full url.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"","code":"usual_endpoints"},{"path":"https://lvaudor.github.io/glitter/reference/usual_endpoints.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Usual endpoints: this dataset allows the user to refer to them using a simplified name rather than their full url. — usual_endpoints","text":"data frame usual SPARQL endpoints abbreviated names name abbreviated name SPARQL endpoint url full address SPARQL endpoint label_property property used labelling","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":null,"dir":"Reference","previous_headings":"","what":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"Usual prefixes: dataset allows user refer usual prefixes queries without manually specifying associated urls.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"","code":"usual_prefixes"},{"path":"https://lvaudor.github.io/glitter/reference/usual_prefixes.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Usual prefixes: this dataset allows the user to refer to usual prefixes in their queries without manually specifying the associated urls. — usual_prefixes","text":"data frame usual prefixes type type prefix name prefix url corresponding ontology","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":null,"dir":"Reference","previous_headings":"","what":"Wikidata properties — wd_properties","title":"Wikidata properties — wd_properties","text":"Wikidata properties","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wikidata properties — wd_properties","text":"","code":"wd_properties"},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Wikidata properties — wd_properties","text":"data frame 8939 rows 5 variables: id id type property type label property label description property description altLabel alternative labels","code":""},{"path":"https://lvaudor.github.io/glitter/reference/wd_properties.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Wikidata properties — wd_properties","text":"Wikidata https://query.wikidata.org/#SELECT%20%3Fproperty%20%3FpropertyType%20%3FpropertyLabel%20%3FpropertyDescription%20%3FpropertyAltLabel%0AWHERE%20%7B%0A%20%20%3Fproperty%20wikibase%3ApropertyType%20%3FpropertyType.%0A%20%20SERVICE%20wikibase%3Alabel%20%7Bbd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0AORDER%20BY%20ASC%20%28xsd%3Ainteger%28STRAFTER%28STR%28%3Fproperty%29%2C%20%27P%27%29%29%29","code":""}]

http://data.bnf.fr/ark:/12148/cb15323605w#about
http://data.bnf.fr/ark:/12148/cb151849573https://gallica.bnf.fr/ark:/12148/btv1b53225404dhttp://data.bnf.fr/ark:/12148/cb46659830p#abouthttp://data.bnf.fr/ark:/12148/cb151849573#about
http://data.bnf.fr/ark:/12148/cb15220445p https://gallica.bnf.fr/ark:/12148/btv1b53196844t http://data.bnf.fr/ark:/12148/cb45699412b#about http://data.bnf.fr/ark:/12148/cb15220445p#about
http://data.bnf.fr/ark:/12148/cb151849573https://gallica.bnf.fr/ark:/12148/btv1b53225404dhttp://data.bnf.fr/ark:/12148/cb46659830p#abouthttp://data.bnf.fr/ark:/12148/cb151849573#about
http://data.bnf.fr/ark:/12148/cb153546826 https://gallica.bnf.fr/ark:/12148/btv1b530131629