diff --git a/articles/explore.html b/articles/explore.html index ab3fb43..5913fff 100644 --- a/articles/explore.html +++ b/articles/explore.html @@ -398,7 +398,7 @@

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

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

Which classes have the most insta http://schema.org/PostalAddress -743557 +743990 http://schema.org/Organization -739959 +740486 https://schema.ld.admin.ch/ZefixOrganisation -732504 +732943 http://www.w3.org/ns/locn#Address -732330 +732766 http://filteredpush.org/ontologies/oa/dwcFP#TaxonConcept -670904 +673891 http://filteredpush.org/ontologies/oa/dwcFP#TaxonName -654480 +656276 http://plazi.org/vocab/treatment#Treatment -650414 +649894 http://purl.org/spar/fabio/JournalArticle -327248 +323064 http://purl.org/spar/fabio/Figure -304070 +312476 https://ld.zh.ch/elodzh-ontology/Man @@ -474,7 +474,7 @@

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

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

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

Which classes have the most insta http://schema.org/PostalAddress -743557 +743990 http://schema.org/Organization -739959 +740486 https://schema.ld.admin.ch/ZefixOrganisation -732504 +732943 http://www.w3.org/ns/locn#Address -732330 +732766 http://filteredpush.org/ontologies/oa/dwcFP#TaxonConcept -670904 +673891 http://filteredpush.org/ontologies/oa/dwcFP#TaxonName -654480 +656276 http://plazi.org/vocab/treatment#Treatment -650414 +649894 http://purl.org/spar/fabio/JournalArticle -327248 +323064 http://purl.org/spar/fabio/Figure -304070 +312476 Man @@ -599,7 +599,7 @@

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

What values does a given propert ZH -128207 +128297 BE -66493 +66481 VD -64131 +64187 GE -53692 +53751 AG -43358 +43383 TI -41963 +41977 SG -40500 +40514 ZG -39638 +39677 LU -32935 +32943 VS -32278 +32308 diff --git a/articles/glitter_bibliometry.html b/articles/glitter_bibliometry.html index 01e27f5..d51a456 100644 --- a/articles/glitter_bibliometry.html +++ b/articles/glitter_bibliometry.html @@ -77,7 +77,7 @@ - +
@@ -130,8 +130,8 @@

Entrée par auteur·rice spq_add("?personne foaf:name 'Lise Vaudor'") %>% # récupère les personnes appelées "Lise Vaudor" spq_perform() DT::datatable(test_LV)

-
-

Il existe bien une personne ayant ce nom dans la base de données, qui +

+

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 @@ -156,8 +156,8 @@

Entrée par auteur·riceinteret_LV = requete %>% # garde seulement les étiquettes en français spq_perform() DT::datatable(interet_LV) -
- +
+

Documents d’un·e auteur·rice @@ -213,8 +213,8 @@

Affiliationsspq_perform() DT::datatable(orga_LV)

-
- +
+

Documents @@ -260,8 +260,8 @@

Documentsarrange(desc(date)) %>% head(20) %>% DT::datatable()

-
- +
+
@@ -304,8 +304,8 @@

Identification du laboratoirefilter(!(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)

-
-

Créons maintenant une fonction qui permet de récupérer +

+

Créons maintenant une fonction qui permet de récupérer l’ensemble des documents pour chacune de ces dénominations de laboratoire.

@@ -354,8 +354,8 @@ 

Identification du laboratoire## [1] 1299 6

 DT::datatable(docs_EVS_show) 
-
- +
+
diff --git a/articles/glitter_bibliometry_files/datatables-binding-0.30/datatables.js b/articles/glitter_bibliometry_files/datatables-binding-0.30/datatables.js new file mode 100644 index 0000000..d968d8b --- /dev/null +++ b/articles/glitter_bibliometry_files/datatables-binding-0.30/datatables.js @@ -0,0 +1,1517 @@ +(function() { + +// some helper functions: using a global object DTWidget so that it can be used +// in JS() code, e.g. datatable(options = list(foo = JS('code'))); unlike R's +// dynamic scoping, when 'code' is eval'ed, JavaScript does not know objects +// from the "parent frame", e.g. JS('DTWidget') will not work unless it was made +// a global object +var DTWidget = {}; + +// 123456666.7890 -> 123,456,666.7890 +var markInterval = function(d, digits, interval, mark, decMark, precision) { + x = precision ? d.toPrecision(digits) : d.toFixed(digits); + if (!/^-?[\d.]+$/.test(x)) return x; + var xv = x.split('.'); + if (xv.length > 2) return x; // should have at most one decimal point + xv[0] = xv[0].replace(new RegExp('\\B(?=(\\d{' + interval + '})+(?!\\d))', 'g'), mark); + return xv.join(decMark); +}; + +DTWidget.formatCurrency = function(data, currency, digits, interval, mark, decMark, before, zeroPrint) { + var d = parseFloat(data); + if (isNaN(d)) return ''; + if (zeroPrint !== null && d === 0.0) return zeroPrint; + var res = markInterval(d, digits, interval, mark, decMark); + res = before ? (/^-/.test(res) ? '-' + currency + res.replace(/^-/, '') : currency + res) : + res + currency; + return res; +}; + +DTWidget.formatString = function(data, prefix, suffix) { + var d = data; + if (d === null) return ''; + return prefix + d + suffix; +}; + +DTWidget.formatPercentage = function(data, digits, interval, mark, decMark, zeroPrint) { + var d = parseFloat(data); + if (isNaN(d)) return ''; + if (zeroPrint !== null && d === 0.0) return zeroPrint; + return markInterval(d * 100, digits, interval, mark, decMark) + '%'; +}; + +DTWidget.formatRound = function(data, digits, interval, mark, decMark, zeroPrint) { + var d = parseFloat(data); + if (isNaN(d)) return ''; + if (zeroPrint !== null && d === 0.0) return zeroPrint; + return markInterval(d, digits, interval, mark, decMark); +}; + +DTWidget.formatSignif = function(data, digits, interval, mark, decMark, zeroPrint) { + var d = parseFloat(data); + if (isNaN(d)) return ''; + if (zeroPrint !== null && d === 0.0) return zeroPrint; + return markInterval(d, digits, interval, mark, decMark, true); +}; + +DTWidget.formatDate = function(data, method, params) { + var d = data; + if (d === null) return ''; + // (new Date('2015-10-28')).toDateString() may return 2015-10-27 because the + // actual time created could be like 'Tue Oct 27 2015 19:00:00 GMT-0500 (CDT)', + // i.e. the date-only string is treated as UTC time instead of local time + if ((method === 'toDateString' || method === 'toLocaleDateString') && /^\d{4,}\D\d{2}\D\d{2}$/.test(d)) { + d = d.split(/\D/); + d = new Date(d[0], d[1] - 1, d[2]); + } else { + d = new Date(d); + } + return d[method].apply(d, params); +}; + +window.DTWidget = DTWidget; + +// A helper function to update the properties of existing filters +var setFilterProps = function(td, props) { + // Update enabled/disabled state + var $input = $(td).find('input').first(); + var searchable = $input.data('searchable'); + $input.prop('disabled', !searchable || props.disabled); + + // Based on the filter type, set its new values + var type = td.getAttribute('data-type'); + if (['factor', 'logical'].includes(type)) { + // Reformat the new dropdown options for use with selectize + var new_vals = props.params.options.map(function(item) { + return { text: item, value: item }; + }); + + // Find the selectize object + var dropdown = $(td).find('.selectized').eq(0)[0].selectize; + + // Note the current values + var old_vals = dropdown.getValue(); + + // Remove the existing values + dropdown.clearOptions(); + + // Add the new options + dropdown.addOption(new_vals); + + // Preserve the existing values + dropdown.setValue(old_vals); + + } else if (['number', 'integer', 'date', 'time'].includes(type)) { + // Apply internal scaling to new limits. Updating scale not yet implemented. + var slider = $(td).find('.noUi-target').eq(0); + var scale = Math.pow(10, Math.max(0, +slider.data('scale') || 0)); + var new_vals = [props.params.min * scale, props.params.max * scale]; + + // Note what the new limits will be just for this filter + var new_lims = new_vals.slice(); + + // Determine the current values and limits + var old_vals = slider.val().map(Number); + var old_lims = slider.noUiSlider('options').range; + old_lims = [old_lims.min, old_lims.max]; + + // Preserve the current values if filters have been applied; otherwise, apply no filtering + if (old_vals[0] != old_lims[0]) { + new_vals[0] = Math.max(old_vals[0], new_vals[0]); + } + + if (old_vals[1] != old_lims[1]) { + new_vals[1] = Math.min(old_vals[1], new_vals[1]); + } + + // Update the endpoints of the slider + slider.noUiSlider({ + start: new_vals, + range: {'min': new_lims[0], 'max': new_lims[1]} + }, true); + } +}; + +var transposeArray2D = function(a) { + return a.length === 0 ? a : HTMLWidgets.transposeArray2D(a); +}; + +var crosstalkPluginsInstalled = false; + +function maybeInstallCrosstalkPlugins() { + if (crosstalkPluginsInstalled) + return; + crosstalkPluginsInstalled = true; + + $.fn.dataTable.ext.afnFiltering.push( + function(oSettings, aData, iDataIndex) { + var ctfilter = oSettings.nTable.ctfilter; + if (ctfilter && !ctfilter[iDataIndex]) + return false; + + var ctselect = oSettings.nTable.ctselect; + if (ctselect && !ctselect[iDataIndex]) + return false; + + return true; + } + ); +} + +HTMLWidgets.widget({ + name: "datatables", + type: "output", + renderOnNullValue: true, + initialize: function(el, width, height) { + // in order that the type=number inputs return a number + $.valHooks.number = { + get: function(el) { + var value = parseFloat(el.value); + return isNaN(value) ? "" : value; + } + }; + $(el).html(' '); + return { + data: null, + ctfilterHandle: new crosstalk.FilterHandle(), + ctfilterSubscription: null, + ctselectHandle: new crosstalk.SelectionHandle(), + ctselectSubscription: null + }; + }, + renderValue: function(el, data, instance) { + if (el.offsetWidth === 0 || el.offsetHeight === 0) { + instance.data = data; + return; + } + instance.data = null; + var $el = $(el); + $el.empty(); + + if (data === null) { + $el.append(' '); + // clear previous Shiny inputs (if any) + for (var i in instance.clearInputs) instance.clearInputs[i](); + instance.clearInputs = {}; + return; + } + + var crosstalkOptions = data.crosstalkOptions; + if (!crosstalkOptions) crosstalkOptions = { + 'key': null, 'group': null + }; + if (crosstalkOptions.group) { + maybeInstallCrosstalkPlugins(); + instance.ctfilterHandle.setGroup(crosstalkOptions.group); + instance.ctselectHandle.setGroup(crosstalkOptions.group); + } + + // if we are in the viewer then we always want to fillContainer and + // and autoHideNavigation (unless the user has explicitly set these) + if (window.HTMLWidgets.viewerMode) { + if (!data.hasOwnProperty("fillContainer")) + data.fillContainer = true; + if (!data.hasOwnProperty("autoHideNavigation")) + data.autoHideNavigation = true; + } + + // propagate fillContainer to instance (so we have it in resize) + instance.fillContainer = data.fillContainer; + + var cells = data.data; + + if (cells instanceof Array) cells = transposeArray2D(cells); + + $el.append(data.container); + var $table = $el.find('table'); + if (data.class) $table.addClass(data.class); + if (data.caption) $table.prepend(data.caption); + + if (!data.selection) data.selection = { + mode: 'none', selected: null, target: 'row', selectable: null + }; + if (HTMLWidgets.shinyMode && data.selection.mode !== 'none' && + data.selection.target === 'row+column') { + if ($table.children('tfoot').length === 0) { + $table.append($('')); + $table.find('thead tr').clone().appendTo($table.find('tfoot')); + } + } + + // column filters + var filterRow; + switch (data.filter) { + case 'top': + $table.children('thead').append(data.filterHTML); + filterRow = $table.find('thead tr:last td'); + break; + case 'bottom': + if ($table.children('tfoot').length === 0) { + $table.append($('')); + } + $table.children('tfoot').prepend(data.filterHTML); + filterRow = $table.find('tfoot tr:first td'); + break; + } + + var options = { searchDelay: 1000 }; + if (cells !== null) $.extend(options, { + data: cells + }); + + // options for fillContainer + var bootstrapActive = typeof($.fn.popover) != 'undefined'; + if (instance.fillContainer) { + + // force scrollX/scrollY and turn off autoWidth + options.scrollX = true; + options.scrollY = "100px"; // can be any value, we'll adjust below + + // if we aren't paginating then move around the info/filter controls + // to save space at the bottom and rephrase the info callback + if (data.options.paging === false) { + + // we know how to do this cleanly for bootstrap, not so much + // for other themes/layouts + if (bootstrapActive) { + options.dom = "<'row'<'col-sm-4'i><'col-sm-8'f>>" + + "<'row'<'col-sm-12'tr>>"; + } + + options.fnInfoCallback = function(oSettings, iStart, iEnd, + iMax, iTotal, sPre) { + return Number(iTotal).toLocaleString() + " records"; + }; + } + } + + // auto hide navigation if requested + // Note, this only works on client-side processing mode as on server-side, + // cells (data.data) is null; In addition, we require the pageLength option + // being provided explicitly to enable this. Despite we may be able to deduce + // the default value of pageLength, it may complicate things so we'd rather + // put this responsiblity to users and warn them on the R side. + if (data.autoHideNavigation === true && data.options.paging !== false) { + // strip all nav if length >= cells + if ((cells instanceof Array) && data.options.pageLength >= cells.length) + options.dom = bootstrapActive ? "<'row'<'col-sm-12'tr>>" : "t"; + // alternatively lean things out for flexdashboard mobile portrait + else if (bootstrapActive && window.FlexDashboard && window.FlexDashboard.isMobilePhone()) + options.dom = "<'row'<'col-sm-12'f>>" + + "<'row'<'col-sm-12'tr>>" + + "<'row'<'col-sm-12'p>>"; + } + + $.extend(true, options, data.options || {}); + + var searchCols = options.searchCols; + if (searchCols) { + searchCols = searchCols.map(function(x) { + return x === null ? '' : x.search; + }); + // FIXME: this means I don't respect the escapeRegex setting + delete options.searchCols; + } + + // server-side processing? + var server = options.serverSide === true; + + // use the dataSrc function to pre-process JSON data returned from R + var DT_rows_all = [], DT_rows_current = []; + if (server && HTMLWidgets.shinyMode && typeof options.ajax === 'object' && + /^session\/[\da-z]+\/dataobj/.test(options.ajax.url) && !options.ajax.dataSrc) { + options.ajax.dataSrc = function(json) { + DT_rows_all = $.makeArray(json.DT_rows_all); + DT_rows_current = $.makeArray(json.DT_rows_current); + var data = json.data; + if (!colReorderEnabled()) return data; + var table = $table.DataTable(), order = table.colReorder.order(), flag = true, i, j, row; + for (i = 0; i < order.length; ++i) if (order[i] !== i) flag = false; + if (flag) return data; + for (i = 0; i < data.length; ++i) { + row = data[i].slice(); + for (j = 0; j < order.length; ++j) data[i][j] = row[order[j]]; + } + return data; + }; + } + + var thiz = this; + if (instance.fillContainer) $table.on('init.dt', function(e) { + thiz.fillAvailableHeight(el, $(el).innerHeight()); + }); + // If the page contains serveral datatables and one of which enables colReorder, + // the table.colReorder.order() function will exist but throws error when called. + // So it seems like the only way to know if colReorder is enabled or not is to + // check the options. + var colReorderEnabled = function() { return "colReorder" in options; }; + var table = $table.DataTable(options); + $el.data('datatable', table); + + // Unregister previous Crosstalk event subscriptions, if they exist + if (instance.ctfilterSubscription) { + instance.ctfilterHandle.off("change", instance.ctfilterSubscription); + instance.ctfilterSubscription = null; + } + if (instance.ctselectSubscription) { + instance.ctselectHandle.off("change", instance.ctselectSubscription); + instance.ctselectSubscription = null; + } + + if (!crosstalkOptions.group) { + $table[0].ctfilter = null; + $table[0].ctselect = null; + } else { + var key = crosstalkOptions.key; + function keysToMatches(keys) { + if (!keys) { + return null; + } else { + var selectedKeys = {}; + for (var i = 0; i < keys.length; i++) { + selectedKeys[keys[i]] = true; + } + var matches = {}; + for (var j = 0; j < key.length; j++) { + if (selectedKeys[key[j]]) + matches[j] = true; + } + return matches; + } + } + + function applyCrosstalkFilter(e) { + $table[0].ctfilter = keysToMatches(e.value); + table.draw(); + } + instance.ctfilterSubscription = instance.ctfilterHandle.on("change", applyCrosstalkFilter); + applyCrosstalkFilter({value: instance.ctfilterHandle.filteredKeys}); + + function applyCrosstalkSelection(e) { + if (e.sender !== instance.ctselectHandle) { + table + .rows('.' + selClass, {search: 'applied'}) + .nodes() + .to$() + .removeClass(selClass); + if (selectedRows) + changeInput('rows_selected', selectedRows(), void 0, true); + } + + if (e.sender !== instance.ctselectHandle && e.value && e.value.length) { + var matches = keysToMatches(e.value); + + // persistent selection with plotly (& leaflet) + var ctOpts = crosstalk.var("plotlyCrosstalkOpts").get() || {}; + if (ctOpts.persistent === true) { + var matches = $.extend(matches, $table[0].ctselect); + } + + $table[0].ctselect = matches; + table.draw(); + } else { + if ($table[0].ctselect) { + $table[0].ctselect = null; + table.draw(); + } + } + } + instance.ctselectSubscription = instance.ctselectHandle.on("change", applyCrosstalkSelection); + // TODO: This next line doesn't seem to work when renderDataTable is used + applyCrosstalkSelection({value: instance.ctselectHandle.value}); + } + + var inArray = function(val, array) { + return $.inArray(val, $.makeArray(array)) > -1; + }; + + // search the i-th column + var searchColumn = function(i, value) { + var regex = false, ci = true; + if (options.search) { + regex = options.search.regex, + ci = options.search.caseInsensitive !== false; + } + return table.column(i).search(value, regex, !regex, ci); + }; + + if (data.filter !== 'none') { + + filterRow.each(function(i, td) { + + var $td = $(td), type = $td.data('type'), filter; + var $input = $td.children('div').first().children('input'); + var disabled = $input.prop('disabled'); + var searchable = table.settings()[0].aoColumns[i].bSearchable; + $input.prop('disabled', !searchable || disabled); + $input.data('searchable', searchable); // for updating later + $input.on('input blur', function() { + $input.next('span').toggle(Boolean($input.val())); + }); + // Bootstrap sets pointer-events to none and we won't be able to click + // the clear button + $input.next('span').css('pointer-events', 'auto').hide().click(function() { + $(this).hide().prev('input').val('').trigger('input').focus(); + }); + var searchCol; // search string for this column + if (searchCols && searchCols[i]) { + searchCol = searchCols[i]; + $input.val(searchCol).trigger('input'); + } + var $x = $td.children('div').last(); + + // remove the overflow: hidden attribute of the scrollHead + // (otherwise the scrolling table body obscures the filters) + // The workaround and the discussion from + // https://github.com/rstudio/DT/issues/554#issuecomment-518007347 + // Otherwise the filter selection will not be anchored to the values + // when the columns number is many and scrollX is enabled. + var scrollHead = $(el).find('.dataTables_scrollHead,.dataTables_scrollFoot'); + var cssOverflowHead = scrollHead.css('overflow'); + var scrollBody = $(el).find('.dataTables_scrollBody'); + var cssOverflowBody = scrollBody.css('overflow'); + var scrollTable = $(el).find('.dataTables_scroll'); + var cssOverflowTable = scrollTable.css('overflow'); + if (cssOverflowHead === 'hidden') { + $x.on('show hide', function(e) { + if (e.type === 'show') { + scrollHead.css('overflow', 'visible'); + scrollBody.css('overflow', 'visible'); + scrollTable.css('overflow-x', 'scroll'); + } else { + scrollHead.css('overflow', cssOverflowHead); + scrollBody.css('overflow', cssOverflowBody); + scrollTable.css('overflow-x', cssOverflowTable); + } + }); + $x.css('z-index', 25); + } + + if (inArray(type, ['factor', 'logical'])) { + $input.on({ + click: function() { + $input.parent().hide(); $x.show().trigger('show'); filter[0].selectize.focus(); + }, + input: function() { + var v1 = JSON.stringify(filter[0].selectize.getValue()), v2 = $input.val(); + if (v1 === '[]') v1 = ''; + if (v1 !== v2) filter[0].selectize.setValue(v2 === '' ? [] : JSON.parse(v2)); + } + }); + var $input2 = $x.children('select'); + filter = $input2.selectize({ + options: $input2.data('options').map(function(v, i) { + return ({text: v, value: v}); + }), + plugins: ['remove_button'], + hideSelected: true, + onChange: function(value) { + if (value === null) value = []; // compatibility with jQuery 3.0 + $input.val(value.length ? JSON.stringify(value) : ''); + if (value.length) $input.trigger('input'); + $input.attr('title', $input.val()); + if (server) { + table.column(i).search(value.length ? JSON.stringify(value) : '').draw(); + return; + } + // turn off filter if nothing selected + $td.data('filter', value.length > 0); + table.draw(); // redraw table, and filters will be applied + } + }); + if (searchCol) filter[0].selectize.setValue(JSON.parse(searchCol)); + filter[0].selectize.on('blur', function() { + $x.hide().trigger('hide'); $input.parent().show(); $input.trigger('blur'); + }); + filter.next('div').css('margin-bottom', 'auto'); + } else if (type === 'character') { + var fun = function() { + searchColumn(i, $input.val()).draw(); + }; + if (server) { + fun = $.fn.dataTable.util.throttle(fun, options.searchDelay); + } + $input.on('input', fun); + } else if (inArray(type, ['number', 'integer', 'date', 'time'])) { + var $x0 = $x; + $x = $x0.children('div').first(); + $x0.css({ + 'background-color': '#fff', + 'border': '1px #ddd solid', + 'border-radius': '4px', + 'padding': data.vertical ? '35px 20px': '20px 20px 10px 20px' + }); + var $spans = $x0.children('span').css({ + 'margin-top': data.vertical ? '0' : '10px', + 'white-space': 'nowrap' + }); + var $span1 = $spans.first(), $span2 = $spans.last(); + var r1 = +$x.data('min'), r2 = +$x.data('max'); + // when the numbers are too small or have many decimal places, the + // slider may have numeric precision problems (#150) + var scale = Math.pow(10, Math.max(0, +$x.data('scale') || 0)); + r1 = Math.round(r1 * scale); r2 = Math.round(r2 * scale); + var scaleBack = function(x, scale) { + if (scale === 1) return x; + var d = Math.round(Math.log(scale) / Math.log(10)); + // to avoid problems like 3.423/100 -> 0.034230000000000003 + return (x / scale).toFixed(d); + }; + var slider_min = function() { + return filter.noUiSlider('options').range.min; + }; + var slider_max = function() { + return filter.noUiSlider('options').range.max; + }; + $input.on({ + focus: function() { + $x0.show().trigger('show'); + // first, make sure the slider div leaves at least 20px between + // the two (slider value) span's + $x0.width(Math.max(160, $span1.outerWidth() + $span2.outerWidth() + 20)); + // then, if the input is really wide or slider is vertical, + // make the slider the same width as the input + if ($x0.outerWidth() < $input.outerWidth() || data.vertical) { + $x0.outerWidth($input.outerWidth()); + } + // make sure the slider div does not reach beyond the right margin + if ($(window).width() < $x0.offset().left + $x0.width()) { + $x0.offset({ + 'left': $input.offset().left + $input.outerWidth() - $x0.outerWidth() + }); + } + }, + blur: function() { + $x0.hide().trigger('hide'); + }, + input: function() { + if ($input.val() === '') filter.val([slider_min(), slider_max()]); + }, + change: function() { + var v = $input.val().replace(/\s/g, ''); + if (v === '') return; + v = v.split('...'); + if (v.length !== 2) { + $input.parent().addClass('has-error'); + return; + } + if (v[0] === '') v[0] = slider_min(); + if (v[1] === '') v[1] = slider_max(); + $input.parent().removeClass('has-error'); + // treat date as UTC time at midnight + var strTime = function(x) { + var s = type === 'date' ? 'T00:00:00Z' : ''; + var t = new Date(x + s).getTime(); + // add 10 minutes to date since it does not hurt the date, and + // it helps avoid the tricky floating point arithmetic problems, + // e.g. sometimes the date may be a few milliseconds earlier + // than the midnight due to precision problems in noUiSlider + return type === 'date' ? t + 3600000 : t; + }; + if (inArray(type, ['date', 'time'])) { + v[0] = strTime(v[0]); + v[1] = strTime(v[1]); + } + if (v[0] != slider_min()) v[0] *= scale; + if (v[1] != slider_max()) v[1] *= scale; + filter.val(v); + } + }); + var formatDate = function(d, isoFmt) { + d = scaleBack(d, scale); + if (type === 'number') return d; + if (type === 'integer') return parseInt(d); + var x = new Date(+d); + var fmt = ('filterDateFmt' in data) ? data.filterDateFmt[i] : undefined; + if (fmt !== undefined && isoFmt === false) return x[fmt.method].apply(x, fmt.params); + if (type === 'date') { + var pad0 = function(x) { + return ('0' + x).substr(-2, 2); + }; + return x.getUTCFullYear() + '-' + pad0(1 + x.getUTCMonth()) + + '-' + pad0(x.getUTCDate()); + } else { + return x.toISOString(); + } + }; + var opts = type === 'date' ? { step: 60 * 60 * 1000 } : + type === 'integer' ? { step: 1 } : {}; + + opts.orientation = data.vertical ? 'vertical': 'horizontal'; + opts.direction = data.vertical ? 'rtl': 'ltr'; + + filter = $x.noUiSlider($.extend({ + start: [r1, r2], + range: {min: r1, max: r2}, + connect: true + }, opts)); + if (scale > 1) (function() { + var t1 = r1, t2 = r2; + var val = filter.val(); + while (val[0] > r1 || val[1] < r2) { + if (val[0] > r1) { + t1 -= val[0] - r1; + } + if (val[1] < r2) { + t2 += r2 - val[1]; + } + filter = $x.noUiSlider($.extend({ + start: [t1, t2], + range: {min: t1, max: t2}, + connect: true + }, opts), true); + val = filter.val(); + } + r1 = t1; r2 = t2; + })(); + var updateSliderText = function(v1, v2) { + $span1.text(formatDate(v1, false)); $span2.text(formatDate(v2, false)); + }; + updateSliderText(r1, r2); + var updateSlider = function(e) { + var val = filter.val(); + // turn off filter if in full range + $td.data('filter', val[0] > slider_min() || val[1] < slider_max()); + var v1 = formatDate(val[0]), v2 = formatDate(val[1]), ival; + if ($td.data('filter')) { + ival = v1 + ' ... ' + v2; + $input.attr('title', ival).val(ival).trigger('input'); + } else { + $input.attr('title', '').val(''); + } + updateSliderText(val[0], val[1]); + if (e.type === 'slide') return; // no searching when sliding only + if (server) { + table.column(i).search($td.data('filter') ? ival : '').draw(); + return; + } + table.draw(); + }; + filter.on({ + set: updateSlider, + slide: updateSlider + }); + } + + // server-side processing will be handled by R (or whatever server + // language you use); the following code is only needed for client-side + // processing + if (server) { + // if a search string has been pre-set, search now + if (searchCol) searchColumn(i, searchCol).draw(); + return; + } + + var customFilter = function(settings, data, dataIndex) { + // there is no way to attach a search function to a specific table, + // and we need to make sure a global search function is not applied to + // all tables (i.e. a range filter in a previous table should not be + // applied to the current table); we use the settings object to + // determine if we want to perform searching on the current table, + // since settings.sTableId will be different to different tables + if (table.settings()[0] !== settings) return true; + // no filter on this column or no need to filter this column + if (typeof filter === 'undefined' || !$td.data('filter')) return true; + + var r = filter.val(), v, r0, r1; + var i_data = function(i) { + if (!colReorderEnabled()) return i; + var order = table.colReorder.order(), k; + for (k = 0; k < order.length; ++k) if (order[k] === i) return k; + return i; // in theory it will never be here... + } + v = data[i_data(i)]; + if (type === 'number' || type === 'integer') { + v = parseFloat(v); + // how to handle NaN? currently exclude these rows + if (isNaN(v)) return(false); + r0 = parseFloat(scaleBack(r[0], scale)) + r1 = parseFloat(scaleBack(r[1], scale)); + if (v >= r0 && v <= r1) return true; + } else if (type === 'date' || type === 'time') { + v = new Date(v); + r0 = new Date(r[0] / scale); r1 = new Date(r[1] / scale); + if (v >= r0 && v <= r1) return true; + } else if (type === 'factor') { + if (r.length === 0 || inArray(v, r)) return true; + } else if (type === 'logical') { + if (r.length === 0) return true; + if (inArray(v === '' ? 'na' : v, r)) return true; + } + return false; + }; + + $.fn.dataTable.ext.search.push(customFilter); + + // search for the preset search strings if it is non-empty + if (searchCol) { + if (inArray(type, ['factor', 'logical'])) { + filter[0].selectize.setValue(JSON.parse(searchCol)); + } else if (type === 'character') { + $input.trigger('input'); + } else if (inArray(type, ['number', 'integer', 'date', 'time'])) { + $input.trigger('change'); + } + } + + }); + + } + + // highlight search keywords + var highlight = function() { + var body = $(table.table().body()); + // removing the old highlighting first + body.unhighlight(); + + // don't highlight the "not found" row, so we get the rows using the api + if (table.rows({ filter: 'applied' }).data().length === 0) return; + // highlight global search keywords + body.highlight($.trim(table.search()).split(/\s+/)); + // then highlight keywords from individual column filters + if (filterRow) filterRow.each(function(i, td) { + var $td = $(td), type = $td.data('type'); + if (type !== 'character') return; + var $input = $td.children('div').first().children('input'); + var column = table.column(i).nodes().to$(), + val = $.trim($input.val()); + if (type !== 'character' || val === '') return; + column.highlight(val.split(/\s+/)); + }); + }; + + if (options.searchHighlight) { + table + .on('draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth', highlight) + .on('destroy', function() { + // remove event handler + table.off('draw.dt.dth column-visibility.dt.dth column-reorder.dt.dth'); + }); + + // Set the option for escaping regex characters in our search string. This will be used + // for all future matching. + jQuery.fn.highlight.options.escapeRegex = (!options.search || !options.search.regex); + + // initial highlight for state saved conditions and initial states + highlight(); + } + + // run the callback function on the table instance + if (typeof data.callback === 'function') data.callback(table); + + // double click to edit the cell, row, column, or all cells + if (data.editable) table.on('dblclick.dt', 'tbody td', function(e) { + // only bring up the editor when the cell itself is dbclicked, and ignore + // other dbclick events bubbled up (e.g. from the ) + if (e.target !== this) return; + var target = [], immediate = false; + switch (data.editable.target) { + case 'cell': + target = [this]; + immediate = true; // edit will take effect immediately + break; + case 'row': + target = table.cells(table.cell(this).index().row, '*').nodes(); + break; + case 'column': + target = table.cells('*', table.cell(this).index().column).nodes(); + break; + case 'all': + target = table.cells().nodes(); + break; + default: + throw 'The editable parameter must be "cell", "row", "column", or "all"'; + } + var disableCols = data.editable.disable ? data.editable.disable.columns : null; + var numericCols = data.editable.numeric; + var areaCols = data.editable.area; + var dateCols = data.editable.date; + for (var i = 0; i < target.length; i++) { + (function(cell, current) { + var $cell = $(cell), html = $cell.html(); + var _cell = table.cell(cell), value = _cell.data(), index = _cell.index().column; + var $input; + if (inArray(index, numericCols)) { + $input = $(''); + } else if (inArray(index, areaCols)) { + $input = $(''); + } else if (inArray(index, dateCols)) { + $input = $(''); + } else { + $input = $(''); + } + if (!immediate) { + $cell.data('input', $input).data('html', html); + $input.attr('title', 'Hit Ctrl+Enter to finish editing, or Esc to cancel'); + } + $input.val(value); + if (inArray(index, disableCols)) { + $input.attr('readonly', '').css('filter', 'invert(25%)'); + } + $cell.empty().append($input); + if (cell === current) $input.focus(); + $input.css('width', '100%'); + + if (immediate) $input.on('blur', function(e) { + var valueNew = $input.val(); + if (valueNew !== value) { + _cell.data(valueNew); + if (HTMLWidgets.shinyMode) { + changeInput('cell_edit', [cellInfo(cell)], 'DT.cellInfo', null, {priority: 'event'}); + } + // for server-side processing, users have to call replaceData() to update the table + if (!server) table.draw(false); + } else { + $cell.html(html); + } + }).on('keyup', function(e) { + // hit Escape to cancel editing + if (e.keyCode === 27) $input.trigger('blur'); + }); + + // bulk edit (row, column, or all) + if (!immediate) $input.on('keyup', function(e) { + var removeInput = function($cell, restore) { + $cell.data('input').remove(); + if (restore) $cell.html($cell.data('html')); + } + if (e.keyCode === 27) { + for (var i = 0; i < target.length; i++) { + removeInput($(target[i]), true); + } + } else if (e.keyCode === 13 && e.ctrlKey) { + // Ctrl + Enter + var cell, $cell, _cell, cellData = []; + for (var i = 0; i < target.length; i++) { + cell = target[i]; $cell = $(cell); _cell = table.cell(cell); + _cell.data($cell.data('input').val()); + HTMLWidgets.shinyMode && cellData.push(cellInfo(cell)); + removeInput($cell, false); + } + if (HTMLWidgets.shinyMode) { + changeInput('cell_edit', cellData, 'DT.cellInfo', null, {priority: "event"}); + } + if (!server) table.draw(false); + } + }); + })(target[i], this); + } + }); + + // interaction with shiny + if (!HTMLWidgets.shinyMode && !crosstalkOptions.group) return; + + var methods = {}; + var shinyData = {}; + + methods.updateCaption = function(caption) { + if (!caption) return; + $table.children('caption').replaceWith(caption); + } + + // register clear functions to remove input values when the table is removed + instance.clearInputs = {}; + + var changeInput = function(id, value, type, noCrosstalk, opts) { + var event = id; + id = el.id + '_' + id; + if (type) id = id + ':' + type; + // do not update if the new value is the same as old value + if (event !== 'cell_edit' && !/_clicked$/.test(event) && shinyData.hasOwnProperty(id) && shinyData[id] === JSON.stringify(value)) + return; + shinyData[id] = JSON.stringify(value); + if (HTMLWidgets.shinyMode && Shiny.setInputValue) { + Shiny.setInputValue(id, value, opts); + if (!instance.clearInputs[id]) instance.clearInputs[id] = function() { + Shiny.setInputValue(id, null); + } + } + + // HACK + if (event === "rows_selected" && !noCrosstalk) { + if (crosstalkOptions.group) { + var keys = crosstalkOptions.key; + var selectedKeys = null; + if (value) { + selectedKeys = []; + for (var i = 0; i < value.length; i++) { + // The value array's contents use 1-based row numbers, so we must + // convert to 0-based before indexing into the keys array. + selectedKeys.push(keys[value[i] - 1]); + } + } + instance.ctselectHandle.set(selectedKeys); + } + } + }; + + var addOne = function(x) { + return x.map(function(i) { return 1 + i; }); + }; + + var unique = function(x) { + var ux = []; + $.each(x, function(i, el){ + if ($.inArray(el, ux) === -1) ux.push(el); + }); + return ux; + } + + // change the row index of a cell + var tweakCellIndex = function(cell) { + var info = cell.index(); + // some cell may not be valid. e.g, #759 + // when using the RowGroup extension, datatables will + // generate the row label and the cells are not part of + // the data thus contain no row/col info + if (info === undefined) + return {row: null, col: null}; + if (server) { + info.row = DT_rows_current[info.row]; + } else { + info.row += 1; + } + return {row: info.row, col: info.column}; + } + + var cleanSelectedValues = function() { + changeInput('rows_selected', []); + changeInput('columns_selected', []); + changeInput('cells_selected', transposeArray2D([]), 'shiny.matrix'); + } + // #828 we should clean the selection on the server-side when the table reloads + cleanSelectedValues(); + + // a flag to indicates if select extension is initialized or not + var flagSelectExt = table.settings()[0]._select !== undefined; + // the Select extension should only be used in the client mode and + // when the selection.mode is set to none + if (data.selection.mode === 'none' && !server && flagSelectExt) { + var updateRowsSelected = function() { + var rows = table.rows({selected: true}); + var selected = []; + $.each(rows.indexes().toArray(), function(i, v) { + selected.push(v + 1); + }); + changeInput('rows_selected', selected); + } + var updateColsSelected = function() { + var columns = table.columns({selected: true}); + changeInput('columns_selected', columns.indexes().toArray()); + } + var updateCellsSelected = function() { + var cells = table.cells({selected: true}); + var selected = []; + cells.every(function() { + var row = this.index().row; + var col = this.index().column; + selected = selected.concat([[row + 1, col]]); + }); + changeInput('cells_selected', transposeArray2D(selected), 'shiny.matrix'); + } + table.on('select deselect', function(e, dt, type, indexes) { + updateRowsSelected(); + updateColsSelected(); + updateCellsSelected(); + }) + } + + var selMode = data.selection.mode, selTarget = data.selection.target; + var selDisable = data.selection.selectable === false; + if (inArray(selMode, ['single', 'multiple'])) { + var selClass = inArray(data.style, ['bootstrap', 'bootstrap4']) ? 'active' : 'selected'; + // selected1: row indices; selected2: column indices + var initSel = function(x) { + if (x === null || typeof x === 'boolean' || selTarget === 'cell') { + return {rows: [], cols: []}; + } else if (selTarget === 'row') { + return {rows: $.makeArray(x), cols: []}; + } else if (selTarget === 'column') { + return {rows: [], cols: $.makeArray(x)}; + } else if (selTarget === 'row+column') { + return {rows: $.makeArray(x.rows), cols: $.makeArray(x.cols)}; + } + } + var selected = data.selection.selected; + var selected1 = initSel(selected).rows, selected2 = initSel(selected).cols; + // selectable should contain either all positive or all non-positive values, not both + // positive values indicate "selectable" while non-positive values means "nonselectable" + // the assertion is performed on R side. (only column indicides could be zero which indicates + // the row name) + var selectable = data.selection.selectable; + var selectable1 = initSel(selectable).rows, selectable2 = initSel(selectable).cols; + + // After users reorder the rows or filter the table, we cannot use the table index + // directly. Instead, we need this function to find out the rows between the two clicks. + // If user filter the table again between the start click and the end click, the behavior + // would be undefined, but it should not be a problem. + var shiftSelRowsIndex = function(start, end) { + var indexes = server ? DT_rows_all : table.rows({ search: 'applied' }).indexes().toArray(); + start = indexes.indexOf(start); end = indexes.indexOf(end); + // if start is larger than end, we need to swap + if (start > end) { + var tmp = end; end = start; start = tmp; + } + return indexes.slice(start, end + 1); + } + + var serverRowIndex = function(clientRowIndex) { + return server ? DT_rows_current[clientRowIndex] : clientRowIndex + 1; + } + + // row, column, or cell selection + var lastClickedRow; + if (inArray(selTarget, ['row', 'row+column'])) { + // Get the current selected rows. It will also + // update the selected1's value based on the current row selection state + // Note we can't put this function inside selectRows() directly, + // the reason is method.selectRows() will override selected1's value but this + // function will add rows to selected1 (keep the existing selection), which is + // inconsistent with column and cell selection. + var selectedRows = function() { + var rows = table.rows('.' + selClass); + var idx = rows.indexes().toArray(); + if (!server) { + selected1 = addOne(idx); + return selected1; + } + idx = idx.map(function(i) { + return DT_rows_current[i]; + }); + selected1 = selMode === 'multiple' ? unique(selected1.concat(idx)) : idx; + return selected1; + } + // Change selected1's value based on selectable1, then refresh the row state + var onlyKeepSelectableRows = function() { + if (selDisable) { // users can't select; useful when only want backend select + selected1 = []; + return; + } + if (selectable1.length === 0) return; + var nonselectable = selectable1[0] <= 0; + if (nonselectable) { + // should make selectable1 positive + selected1 = $(selected1).not(selectable1.map(function(i) { return -i; })).get(); + } else { + selected1 = $(selected1).filter(selectable1).get(); + } + } + // Change selected1's value based on selectable1, then + // refresh the row selection state according to values in selected1 + var selectRows = function(ignoreSelectable) { + if (!ignoreSelectable) onlyKeepSelectableRows(); + table.$('tr.' + selClass).removeClass(selClass); + if (selected1.length === 0) return; + if (server) { + table.rows({page: 'current'}).every(function() { + if (inArray(DT_rows_current[this.index()], selected1)) { + $(this.node()).addClass(selClass); + } + }); + } else { + var selected0 = selected1.map(function(i) { return i - 1; }); + $(table.rows(selected0).nodes()).addClass(selClass); + } + } + table.on('mousedown.dt', 'tbody tr', function(e) { + var $this = $(this), thisRow = table.row(this); + if (selMode === 'multiple') { + if (e.shiftKey && lastClickedRow !== undefined) { + // select or de-select depends on the last clicked row's status + var flagSel = !$this.hasClass(selClass); + var crtClickedRow = serverRowIndex(thisRow.index()); + if (server) { + var rowsIndex = shiftSelRowsIndex(lastClickedRow, crtClickedRow); + // update current page's selClass + rowsIndex.map(function(i) { + var rowIndex = DT_rows_current.indexOf(i); + if (rowIndex >= 0) { + var row = table.row(rowIndex).nodes().to$(); + var flagRowSel = !row.hasClass(selClass); + if (flagSel === flagRowSel) row.toggleClass(selClass); + } + }); + // update selected1 + if (flagSel) { + selected1 = unique(selected1.concat(rowsIndex)); + } else { + selected1 = selected1.filter(function(index) { + return !inArray(index, rowsIndex); + }); + } + } else { + // js starts from 0 + shiftSelRowsIndex(lastClickedRow - 1, crtClickedRow - 1).map(function(value) { + var row = table.row(value).nodes().to$(); + var flagRowSel = !row.hasClass(selClass); + if (flagSel === flagRowSel) row.toggleClass(selClass); + }); + } + e.preventDefault(); + } else { + $this.toggleClass(selClass); + } + } else { + if ($this.hasClass(selClass)) { + $this.removeClass(selClass); + } else { + table.$('tr.' + selClass).removeClass(selClass); + $this.addClass(selClass); + } + } + if (server && !$this.hasClass(selClass)) { + var id = DT_rows_current[thisRow.index()]; + // remove id from selected1 since its class .selected has been removed + if (inArray(id, selected1)) selected1.splice($.inArray(id, selected1), 1); + } + selectedRows(); // update selected1's value based on selClass + selectRows(false); // only keep the selectable rows + changeInput('rows_selected', selected1); + changeInput('row_last_clicked', serverRowIndex(thisRow.index()), null, null, {priority: 'event'}); + lastClickedRow = serverRowIndex(thisRow.index()); + }); + selectRows(false); // in case users have specified pre-selected rows + // restore selected rows after the table is redrawn (e.g. sort/search/page); + // client-side tables will preserve the selections automatically; for + // server-side tables, we have to *real* row indices are in `selected1` + changeInput('rows_selected', selected1); + if (server) table.on('draw.dt', function(e) { selectRows(false); }); + methods.selectRows = function(selected, ignoreSelectable) { + selected1 = $.makeArray(selected); + selectRows(ignoreSelectable); + changeInput('rows_selected', selected1); + } + } + + if (inArray(selTarget, ['column', 'row+column'])) { + if (selTarget === 'row+column') { + $(table.columns().footer()).css('cursor', 'pointer'); + } + // update selected2's value based on selectable2 + var onlyKeepSelectableCols = function() { + if (selDisable) { // users can't select; useful when only want backend select + selected2 = []; + return; + } + if (selectable2.length === 0) return; + var nonselectable = selectable2[0] <= 0; + if (nonselectable) { + // need to make selectable2 positive + selected2 = $(selected2).not(selectable2.map(function(i) { return -i; })).get(); + } else { + selected2 = $(selected2).filter(selectable2).get(); + } + } + // update selected2 and then + // refresh the col selection state according to values in selected2 + var selectCols = function(ignoreSelectable) { + if (!ignoreSelectable) onlyKeepSelectableCols(); + // if selected2 is not a valide index (e.g., larger than the column number) + // table.columns(selected2) will fail and result in a blank table + // this is different from the table.rows(), where the out-of-range indexes + // doesn't affect at all + selected2 = $(selected2).filter(table.columns().indexes()).get(); + table.columns().nodes().flatten().to$().removeClass(selClass); + if (selected2.length > 0) + table.columns(selected2).nodes().flatten().to$().addClass(selClass); + } + var callback = function() { + var colIdx = selTarget === 'column' ? table.cell(this).index().column : + $.inArray(this, table.columns().footer()), + thisCol = $(table.column(colIdx).nodes()); + if (colIdx === -1) return; + if (thisCol.hasClass(selClass)) { + thisCol.removeClass(selClass); + selected2.splice($.inArray(colIdx, selected2), 1); + } else { + if (selMode === 'single') $(table.cells().nodes()).removeClass(selClass); + thisCol.addClass(selClass); + selected2 = selMode === 'single' ? [colIdx] : unique(selected2.concat([colIdx])); + } + selectCols(false); // update selected2 based on selectable + changeInput('columns_selected', selected2); + } + if (selTarget === 'column') { + $(table.table().body()).on('click.dt', 'td', callback); + } else { + $(table.table().footer()).on('click.dt', 'tr th', callback); + } + selectCols(false); // in case users have specified pre-selected columns + changeInput('columns_selected', selected2); + if (server) table.on('draw.dt', function(e) { selectCols(false); }); + methods.selectColumns = function(selected, ignoreSelectable) { + selected2 = $.makeArray(selected); + selectCols(ignoreSelectable); + changeInput('columns_selected', selected2); + } + } + + if (selTarget === 'cell') { + var selected3 = [], selectable3 = []; + if (selected !== null) selected3 = selected; + if (selectable !== null && typeof selectable !== 'boolean') selectable3 = selectable; + var findIndex = function(ij, sel) { + for (var i = 0; i < sel.length; i++) { + if (ij[0] === sel[i][0] && ij[1] === sel[i][1]) return i; + } + return -1; + } + // Change selected3's value based on selectable3, then refresh the cell state + var onlyKeepSelectableCells = function() { + if (selDisable) { // users can't select; useful when only want backend select + selected3 = []; + return; + } + if (selectable3.length === 0) return; + var nonselectable = selectable3[0][0] <= 0; + var out = []; + if (nonselectable) { + selected3.map(function(ij) { + // should make selectable3 positive + if (findIndex([-ij[0], -ij[1]], selectable3) === -1) { out.push(ij); } + }); + } else { + selected3.map(function(ij) { + if (findIndex(ij, selectable3) > -1) { out.push(ij); } + }); + } + selected3 = out; + } + // Change selected3's value based on selectable3, then + // refresh the cell selection state according to values in selected3 + var selectCells = function(ignoreSelectable) { + if (!ignoreSelectable) onlyKeepSelectableCells(); + table.$('td.' + selClass).removeClass(selClass); + if (selected3.length === 0) return; + if (server) { + table.cells({page: 'current'}).every(function() { + var info = tweakCellIndex(this); + if (findIndex([info.row, info.col], selected3) > -1) + $(this.node()).addClass(selClass); + }); + } else { + selected3.map(function(ij) { + $(table.cell(ij[0] - 1, ij[1]).node()).addClass(selClass); + }); + } + }; + table.on('click.dt', 'tbody td', function() { + var $this = $(this), info = tweakCellIndex(table.cell(this)); + if ($this.hasClass(selClass)) { + $this.removeClass(selClass); + selected3.splice(findIndex([info.row, info.col], selected3), 1); + } else { + if (selMode === 'single') $(table.cells().nodes()).removeClass(selClass); + $this.addClass(selClass); + selected3 = selMode === 'single' ? [[info.row, info.col]] : + unique(selected3.concat([[info.row, info.col]])); + } + selectCells(false); // must call this to update selected3 based on selectable3 + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + }); + selectCells(false); // in case users have specified pre-selected columns + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + + if (server) table.on('draw.dt', function(e) { selectCells(false); }); + methods.selectCells = function(selected, ignoreSelectable) { + selected3 = selected ? selected : []; + selectCells(ignoreSelectable); + changeInput('cells_selected', transposeArray2D(selected3), 'shiny.matrix'); + } + } + } + + // expose some table info to Shiny + var updateTableInfo = function(e, settings) { + // TODO: is anyone interested in the page info? + // changeInput('page_info', table.page.info()); + var updateRowInfo = function(id, modifier) { + var idx; + if (server) { + idx = modifier.page === 'current' ? DT_rows_current : DT_rows_all; + } else { + var rows = table.rows($.extend({ + search: 'applied', + page: 'all' + }, modifier)); + idx = addOne(rows.indexes().toArray()); + } + changeInput('rows' + '_' + id, idx); + }; + updateRowInfo('current', {page: 'current'}); + updateRowInfo('all', {}); + } + table.on('draw.dt', updateTableInfo); + updateTableInfo(); + + // state info + table.on('draw.dt column-visibility.dt', function() { + changeInput('state', table.state()); + }); + changeInput('state', table.state()); + + // search info + var updateSearchInfo = function() { + changeInput('search', table.search()); + if (filterRow) changeInput('search_columns', filterRow.toArray().map(function(td) { + return $(td).find('input').first().val(); + })); + } + table.on('draw.dt', updateSearchInfo); + updateSearchInfo(); + + var cellInfo = function(thiz) { + var info = tweakCellIndex(table.cell(thiz)); + info.value = table.cell(thiz).data(); + return info; + } + // the current cell clicked on + table.on('click.dt', 'tbody td', function() { + changeInput('cell_clicked', cellInfo(this), null, null, {priority: 'event'}); + }) + changeInput('cell_clicked', {}); + + // do not trigger table selection when clicking on links unless they have classes + table.on('click.dt', 'tbody td a', function(e) { + if (this.className === '') e.stopPropagation(); + }); + + methods.addRow = function(data, rowname, resetPaging) { + var n = table.columns().indexes().length, d = n - data.length; + if (d === 1) { + data = rowname.concat(data) + } else if (d !== 0) { + console.log(data); + console.log(table.columns().indexes()); + throw 'New data must be of the same length as current data (' + n + ')'; + }; + table.row.add(data).draw(resetPaging); + } + + methods.updateSearch = function(keywords) { + if (keywords.global !== null) + $(table.table().container()).find('input[type=search]').first() + .val(keywords.global).trigger('input'); + var columns = keywords.columns; + if (!filterRow || columns === null) return; + filterRow.toArray().map(function(td, i) { + var v = typeof columns === 'string' ? columns : columns[i]; + if (typeof v === 'undefined') { + console.log('The search keyword for column ' + i + ' is undefined') + return; + } + $(td).find('input').first().val(v).trigger('input'); + searchColumn(i, v); + }); + table.draw(); + } + + methods.hideCols = function(hide, reset) { + if (reset) table.columns().visible(true, false); + table.columns(hide).visible(false); + } + + methods.showCols = function(show, reset) { + if (reset) table.columns().visible(false, false); + table.columns(show).visible(true); + } + + methods.colReorder = function(order, origOrder) { + table.colReorder.order(order, origOrder); + } + + methods.selectPage = function(page) { + if (table.page.info().pages < page || page < 1) { + throw 'Selected page is out of range'; + }; + table.page(page - 1).draw(false); + } + + methods.reloadData = function(resetPaging, clearSelection) { + // empty selections first if necessary + if (methods.selectRows && inArray('row', clearSelection)) methods.selectRows([]); + if (methods.selectColumns && inArray('column', clearSelection)) methods.selectColumns([]); + if (methods.selectCells && inArray('cell', clearSelection)) methods.selectCells([]); + table.ajax.reload(null, resetPaging); + } + + // update table filters (set new limits of sliders) + methods.updateFilters = function(newProps) { + // loop through each filter in the filter row + filterRow.each(function(i, td) { + var k = i; + if (filterRow.length > newProps.length) { + if (i === 0) return; // first column is row names + k = i - 1; + } + // Update the filters to reflect the updated data. + // Allow "falsy" (e.g. NULL) to signify a no-op. + if (newProps[k]) { + setFilterProps(td, newProps[k]); + } + }); + }; + + table.shinyMethods = methods; + }, + resize: function(el, width, height, instance) { + if (instance.data) this.renderValue(el, instance.data, instance); + + // dynamically adjust height if fillContainer = TRUE + if (instance.fillContainer) + this.fillAvailableHeight(el, height); + + this.adjustWidth(el); + }, + + // dynamically set the scroll body to fill available height + // (used with fillContainer = TRUE) + fillAvailableHeight: function(el, availableHeight) { + + // see how much of the table is occupied by header/footer elements + // and use that to compute a target scroll body height + var dtWrapper = $(el).find('div.dataTables_wrapper'); + var dtScrollBody = $(el).find($('div.dataTables_scrollBody')); + var framingHeight = dtWrapper.innerHeight() - dtScrollBody.innerHeight(); + var scrollBodyHeight = availableHeight - framingHeight; + + // we need to set `max-height` to none as datatables library now sets this + // to a fixed height, disabling the ability to resize to fill the window, + // as it will be set to a fixed 100px under such circumstances, e.g., RStudio IDE, + // or FlexDashboard + // see https://github.com/rstudio/DT/issues/951#issuecomment-1026464509 + dtScrollBody.css('max-height', 'none'); + // set the height + dtScrollBody.height(scrollBodyHeight + 'px'); + }, + + // adjust the width of columns; remove the hard-coded widths on table and the + // scroll header when scrollX/Y are enabled + adjustWidth: function(el) { + var $el = $(el), table = $el.data('datatable'); + if (table) table.columns.adjust(); + $el.find('.dataTables_scrollHeadInner').css('width', '') + .children('table').css('margin-left', ''); + } +}); + + if (!HTMLWidgets.shinyMode) return; + + Shiny.addCustomMessageHandler('datatable-calls', function(data) { + var id = data.id; + var el = document.getElementById(id); + var table = el ? $(el).data('datatable') : null; + if (!table) { + console.log("Couldn't find table with id " + id); + return; + } + + var methods = table.shinyMethods, call = data.call; + if (methods[call.method]) { + methods[call.method].apply(table, call.args); + } else { + console.log("Unknown method " + call.method); + } + }); + +})(); diff --git a/articles/glitter_for_Wikidata.html b/articles/glitter_for_Wikidata.html index 4137f77..5a8eabd 100644 --- a/articles/glitter_for_Wikidata.html +++ b/articles/glitter_for_Wikidata.html @@ -301,8 +301,8 @@

Get coordinatesleaflet(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 41e5788..da66bbe 100644 --- a/articles/glitter_for_dataBNF.html +++ b/articles/glitter_for_dataBNF.html @@ -999,17 +999,17 @@

Portraits d’auteur, issus de Galli http://data.bnf.fr/ark:/12148/cb15323605w#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/cb151849573 https://gallica.bnf.fr/ark:/12148/btv1b53225404d http://data.bnf.fr/ark:/12148/cb46659830p#about http://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/cb153546826 https://gallica.bnf.fr/ark:/12148/btv1b530131629 diff --git a/pkgdown.yml b/pkgdown.yml index 09f3e4a..2357c9d 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-05T09:14Z +last_built: 2023-10-12T14:24Z urls: reference: https://lvaudor.github.io/glitter/reference article: https://lvaudor.github.io/glitter/articles diff --git a/reference/spq_perform.html b/reference/spq_perform.html index fa4a8ee..9c0be25 100644 --- a/reference/spq_perform.html +++ b/reference/spq_perform.html @@ -139,11 +139,11 @@

Examples#> # A tibble: 5 × 3 #> city pop city_label #> <chr> <chr> <chr> -#> 1 http://www.wikidata.org/entity/Q1947 525953 Juba -#> 2 http://www.wikidata.org/entity/Q1963 5345000 Khartoum -#> 3 http://www.wikidata.org/entity/Q1960 4715000 Dar es Salaam -#> 4 http://www.wikidata.org/entity/Q2028 257275 Verona -#> 5 http://www.wikidata.org/entity/Q2044 380948 Florence +#> 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 # } diff --git a/reference/spq_tally.html b/reference/spq_tally.html index 54a2320..c92b622 100644 --- a/reference/spq_tally.html +++ b/reference/spq_tally.html @@ -106,7 +106,7 @@

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

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

Examplesspq_group_by(narrative_location_label) %>% spq_tally(sort = TRUE, name = "n_films") %>% spq_perform() -#> # A tibble: 2,742 × 2 +#> # A tibble: 2,747 × 2 #> narrative_location_label n_films #> <chr> <int> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 -#> 5 Los Angeles 1493 -#> 6 England 1426 +#> 5 Los Angeles 1494 +#> 6 England 1427 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 -#> # ℹ 2,732 more rows +#> # ℹ 2,737 more rows # More direct with spq_count() @@ -152,20 +152,20 @@

Examplesspq_label(film, narrative_location) %>% spq_count(narrative_location_label, sort = TRUE, name = "n_films") %>% spq_perform() -#> # A tibble: 2,742 × 2 +#> # A tibble: 2,747 × 2 #> narrative_location_label n_films #> <chr> <int> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 -#> 5 Los Angeles 1493 -#> 6 England 1426 +#> 5 Los Angeles 1494 +#> 6 England 1427 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 -#> # ℹ 2,732 more rows +#> # ℹ 2,737 more rows # } diff --git a/reference/subclasses_of.html b/reference/subclasses_of.html index 897bf9b..057d399 100644 --- a/reference/subclasses_of.html +++ b/reference/subclasses_of.html @@ -76,18 +76,18 @@

ArgumentsExamples

subclasses_of("wd:Q7930989")
 #> # A tibble: 38 × 4
-#>    from        to                                     classes      classes_label
-#>    <chr>       <chr>                                  <chr>        <chr>        
-#>  1 wd:Q7930989 http://www.wikidata.org/entity/Q515    http://www.… city         
-#>  2 wd:Q7930989 http://www.wikidata.org/entity/Q3957   http://www.… town         
-#>  3 wd:Q7930989 http://www.wikidata.org/entity/Q123601 http://www.… cities and t…
-#>  4 wd:Q7930989 http://www.wikidata.org/entity/Q159438 http://www.… Hero City of…
-#>  5 wd:Q7930989 http://www.wikidata.org/entity/Q174844 http://www.… megacity     
-#>  6 wd:Q7930989 http://www.wikidata.org/entity/Q188509 http://www.… suburb       
-#>  7 wd:Q7930989 http://www.wikidata.org/entity/Q692581 http://www.… holy city    
-#>  8 wd:Q7930989 http://www.wikidata.org/entity/Q853252 http://www.… mining town  
-#>  9 wd:Q7930989 http://www.wikidata.org/entity/Q896881 http://www.… city with te…
-#> 10 wd:Q7930989 http://www.wikidata.org/entity/Q902814 http://www.… border town  
+#>    from        to                                      classes     classes_label
+#>    <chr>       <chr>                                   <chr>       <chr>        
+#>  1 wd:Q7930989 http://www.wikidata.org/entity/Q515     http://www… city         
+#>  2 wd:Q7930989 http://www.wikidata.org/entity/Q3957    http://www… town         
+#>  3 wd:Q7930989 http://www.wikidata.org/entity/Q123601  http://www… cities and t…
+#>  4 wd:Q7930989 http://www.wikidata.org/entity/Q159438  http://www… Hero City of…
+#>  5 wd:Q7930989 http://www.wikidata.org/entity/Q174844  http://www… megacity     
+#>  6 wd:Q7930989 http://www.wikidata.org/entity/Q188509  http://www… suburb       
+#>  7 wd:Q7930989 http://www.wikidata.org/entity/Q1392581 http://www… cycling city 
+#>  8 wd:Q7930989 http://www.wikidata.org/entity/Q2035733 http://www… Ecumenopolis 
+#>  9 wd:Q7930989 http://www.wikidata.org/entity/Q692581  http://www… holy city    
+#> 10 wd:Q7930989 http://www.wikidata.org/entity/Q853252  http://www… mining town  
 #> # ℹ 28 more rows
 
diff --git a/search.json b/search.json index 09c1ad6..e08ca6c 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":"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”: 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:","code":"test_LV=spq_init(\"hal\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% # récupère les personnes appelées \"Lise Vaudor\" spq_perform() DT::datatable(test_LV) requete = spq_init(\"hal\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?personne foaf:interest ?interet\") %>% # récupère les centres d'intérêt spq_add(\"?interet skos:prefLabel ?interet_label\") %>% # étiquette les centres d'intérêt spq_filter(lang(interet_label) == 'fr') 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.","code":"requete = spq_init(\"hal\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% # documents crées par créateur spq_add(\"?createur hal:structure ?affil\") %>% # créateur correspond à une affiliation spq_add(\"?createur hal:person ?personne\") %>% # créateur correspond à une personne spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?affil skos:prefLabel ?affiliation\") %>% # é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 ?affil. ## ?createur hal:person ?personne. ## ?personne foaf:name 'Lise Vaudor'. ## ?affil skos:prefLabel ?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 104. Voici les 20 documents les plus récents:","code":"docs_LV = spq_init(endpoint = \"hal\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_add(\"?createur hal:structure ?affil\") %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?affil skos:prefLabel ?affiliation\") %>% spq_add(\"?doc dcterms:type ?type\") %>% spq_add(\"?type skos:prefLabel ?type_label\") %>% spq_filter(lang(type_label) == '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: 104 × 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… ## # ℹ 94 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. 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 (8815). montre ci-dessous les plus récents (à partir de 2020):","code":"labo_EVS = spq_init(endpoint = \"hal\") %>% spq_add(\"?labo skos:prefLabel ?labo_label\") %>% 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… NA ## 2 https://data.archives-ouvertes.fr/revue/115361 Issue 4 of SCS Tr… NA ## 3 https://data.archives-ouvertes.fr/structure/54063 GEVSM NA ## 4 https://data.archives-ouvertes.fr/structure/145345 Environnement Vil… UMR5600 ## 5 https://data.archives-ouvertes.fr/structure/390864 UMR 5600 EVS NA ## 6 https://data.archives-ouvertes.fr/structure/458855 Plateforme ISIG. … NA ## 7 https://data.archives-ouvertes.fr/structure/493368 Environnement Vil… NA ## 8 https://data.archives-ouvertes.fr/structure/516259 UMR CNRS 5600 EVS… NA ## 9 https://data.archives-ouvertes.fr/structure/516301 Environnement Vil… NA ## 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){ lab = paste0(\"<\",lab,\">\") result = spq_init(endpoint = \"hal\") %>% 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_add(\"?doc dcterms:type ?type\") %>% # récupère le type de document spq_add(\"?type skos:prefLabel ?type_label\") %>% # étiquette le type de document spq_filter(lang(type_label) == 'fr') %>% # ... 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\") dim(docs_EVS) ## [1] 8815 6 docs_EVS_show = docs_EVS %>% select(-labo) %>% filter(date >= 2020) %>% unique() %>% select(auteur, date, type, citation, citation) %>% ungroup() ## Adding missing grouping variables: `labo` ## Adding missing grouping variables: `labo`, `labo_label` dim(docs_EVS_show) ## [1] 1299 6 DT::datatable(docs_EVS_show)"},{"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) ## `summarise()` has grouped output by 'date', 'citation'. You can override using ## the `.groups` argument. ggplot(docs_datecitation, aes(x = date, y = n, fill = type)) + geom_bar(stat = \"identity\") + facet_grid(rows = vars(type))"},{"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/count_items.html","id":null,"dir":"Reference","previous_headings":"","what":"Get counts of items directly in classes — count_items","title":"Get counts of items directly in classes — count_items","text":"Get counts items directly classes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get counts of items directly in classes — count_items","text":"","code":"count_items(classes)"},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get counts of items directly in classes — count_items","text":"classes vector wikidata classes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get counts of items directly in classes — count_items","text":"","code":"classes=c(\"wd:Q627272\",\"wd:Q99527517\") count_items(classes) #> Warning: The `.label` argument of `spq_add()` is deprecated as of glitter 0.2.0. #> ℹ Ability to use `.label` will be dropped in next release, use `spq_label()` #> instead. #> ℹ The deprecated feature was likely used in the glitter package. #> Please report the issue at . #> [1] 287 3"},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":null,"dir":"Reference","previous_headings":"","what":"Get description of Wikidata thing — get_description","title":"Get description of Wikidata thing — get_description","text":"Get description Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get description of Wikidata thing — get_description","text":"","code":"get_description(id, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get description of Wikidata thing — get_description","text":"id Wikidata ID, either item (\"Qxxxxx\") property (\"Pxxxxx\"), item . language language description, defaults English (\"en\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get description of Wikidata thing — get_description","text":"","code":"get_description(\"wd:Q431603\") #> [1] \"groups using advocacy in order to influence public opinion and policy\" get_description(\"wd:Q431603\", language=\"es\") #> [1] \"conjunto de personas organizadas con el fin de actuar conjuntamente en defensa de un interés común\""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get description of Wikidata thing — get_info","title":"Get description of Wikidata thing — get_info","text":"Get description Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get description of Wikidata thing — get_info","text":"","code":"get_info(id, language = \"en\", with_labels = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get description of Wikidata thing — get_info","text":"id Wikidata ID, either item (\"wd:Qxxxxx\") property (\"wd:Pxxxxx\"), item . language language description, defaults English (\"en\") with_labels Whether keep labels (Boolean)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get description of Wikidata thing — get_info","text":"","code":"get_info(\"wd:Q431603\") #> $label #> [1] \"advocacy group\" #> #> $description #> [1] \"groups using advocacy in order to influence public opinion and policy\" #>"},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Get label of Wikidata thing — get_label","title":"Get label of Wikidata thing — get_label","text":"Get label Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get label of Wikidata thing — get_label","text":"","code":"get_label(id, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get label of Wikidata thing — get_label","text":"id Wikidata ID, either item (\"Qxxxxx\") property (\"Pxxxxx\"), item . language language label, defaults English (\"en\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get label of Wikidata thing — get_label","text":"","code":"get_label(\"wd:Q431603\") #> [1] \"advocacy group\" get_label(\"wd:Q431603\", language=\"fr\") #> [1] \"groupe de défense d'intérêts\""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"Get Wikidata item property Get unformatted info Wikidata based item property id.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"","code":"get_thing(id)"},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"id Wikidata ID, either item (\"wd:Qxxxxx\") property (\"wd:Pxxxxx\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"","code":"get_thing(\"wd:Q431603\") #> #> \tWikidata item Q431603 #> #> Label:\t\t advocacy group \t[63 other languages available] #> Aliases:\t 利益集团, 利益團體, 壓力團體, 倡仪团体, קבוצות אינטרס, קבוצות בעלי עניין, קבוצת בעלי עניין, קבוצת לחץ, 압력단체, Grupo de presion, Grupos de presión, Grupos de presion, grupo de interes, Surverühm, Huvigrupp, Kepentingan kelompok, Interessensvertretung, Interessensgruppen, Pressure Group, Interessensgruppe, Interessengruppe, Interessenvereinigung, Lobbyorganisation, 利益集団, インタレストグループ, 圧力団体, ロビー団体, プレッシャーグループ, 特別利益団体, λόμπι, ομάδα ειδικού ενδιαφέροντος, Grupa za pritisak, pressiegroep, belangenvereniging, группа давления, группы интересов, лоббистская организация, лоббирующая организация, Интересне групе, baskı grupları, lobici gruplar, savunma grubu, ilginç grup, özel ilgi grubu, lobi organizasyonu, savunuculuk organizasyonu, kulis, lobi grubu, baskı grubu, baskı organizasyonu, baskı örgütü, özel ilgi organizasyonu, گروه فشار, گروه ذی نفوذ, گروه ذینفوذ, Interesseorganisasjoner, Interessegruppe, Interesseforening, interest group, special interest group, lobbying organization, lobby group, advocacy organization, lobbying group, lobbyists, SIG, lobbying organisation, advocacy organisation, special interest organization, special interest organisation, pressure group, pressure organization, pressure organisation, activist organization, activist group, interest organization, groupe de défense, ініцыятыўная група, lobby, lobbyorganisation, kumpulan pengutara, kumpulan penyokong, kumpulan perakuan, kumpulan sokongan, kumpulan pengutaraan, kumpulan anjuran, edunvalvontajärjestö, etujärjestö, ინტერესთა ჯგუფი, intressegrupp, grup d'interès, grup de pressió, lobistična skupina, адвокаційна група, grup de lobby #> Description: groups using advocacy in order to influence public opinion and policy \t[17 other languages available] #> Claims:\t\t 27 #> Sitelinks:\t 45"},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":null,"dir":"Reference","previous_headings":"","what":"Get triple with subject verb object. — get_triple","title":"Get triple with subject verb object. — get_triple","text":"Get triple subject verb object.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get triple with subject verb object. — get_triple","text":"","code":"get_triple( triple = NULL, subject = NULL, verb = NULL, object = NULL, required = TRUE, label = NA, limit = NULL, within_box = c(NA, NA), within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get triple with subject verb object. — get_triple","text":"triple triple 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\")) required whether require triple (Boolean) label vector variables include label column (defaults NA) limit max number items sent back 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/get_triple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get triple with subject verb object. — get_triple","text":"","code":"get_triple(s = \"wd:Q456\", v = \"wdt:P625\", o = \"?coords\") #> # A tibble: 1 × 1 #> coords #> #> 1 Point(4.841388888 45.758888888) get_triple(t = \"wd:Q456 wdt:P625 ?coords\") #> # A tibble: 1 × 1 #> coords #> #> 1 Point(4.841388888 45.758888888)"},{"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_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\")) )"},{"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()","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":"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/Q1947 525953 Juba #> 2 http://www.wikidata.org/entity/Q1963 5345000 Khartoum #> 3 http://www.wikidata.org/entity/Q1960 4715000 Dar es Salaam #> 4 http://www.wikidata.org/entity/Q2028 257275 Verona #> 5 http://www.wikidata.org/entity/Q2044 380948 Florence # }"},{"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 51141 # 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 51141 # 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,742 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1493 #> 6 England 1426 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,732 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,742 × 2 #> narrative_location_label n_films #> #> 1 Indonesia 3088 #> 2 New York City 2544 #> 3 London 2221 #> 4 Paris 1852 #> 5 Los Angeles 1493 #> 6 England 1426 #> 7 Rome 968 #> 8 California 838 #> 9 France 794 #> 10 Hong Kong 707 #> # ℹ 2,732 more rows # }"},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Get subclasses of a Wikidata class — subclasses_of","title":"Get subclasses of a Wikidata class — subclasses_of","text":"Get subclasses Wikidata class","code":""},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get subclasses of a Wikidata class — subclasses_of","text":"","code":"subclasses_of(id, include_self = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get subclasses of a Wikidata class — subclasses_of","text":"id id class include_self whether include class results table","code":""},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get subclasses of a Wikidata class — subclasses_of","text":"","code":"subclasses_of(\"wd:Q7930989\") #> # A tibble: 38 × 4 #> from to classes classes_label #> #> 1 wd:Q7930989 http://www.wikidata.org/entity/Q515 http://www.… city #> 2 wd:Q7930989 http://www.wikidata.org/entity/Q3957 http://www.… town #> 3 wd:Q7930989 http://www.wikidata.org/entity/Q123601 http://www.… cities and t… #> 4 wd:Q7930989 http://www.wikidata.org/entity/Q159438 http://www.… Hero City of… #> 5 wd:Q7930989 http://www.wikidata.org/entity/Q174844 http://www.… megacity #> 6 wd:Q7930989 http://www.wikidata.org/entity/Q188509 http://www.… suburb #> 7 wd:Q7930989 http://www.wikidata.org/entity/Q692581 http://www.… holy city #> 8 wd:Q7930989 http://www.wikidata.org/entity/Q853252 http://www.… mining town #> 9 wd:Q7930989 http://www.wikidata.org/entity/Q896881 http://www.… city with te… #> 10 wd:Q7930989 http://www.wikidata.org/entity/Q902814 http://www.… border town #> # ℹ 28 more rows"},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Get superclasses of a Wikidata class — superclasses_of","title":"Get superclasses of a Wikidata class — superclasses_of","text":"Get superclasses Wikidata class","code":""},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get superclasses of a Wikidata class — superclasses_of","text":"","code":"superclasses_of(id, include_self = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get superclasses of a Wikidata class — superclasses_of","text":"id id class include_self whether include class results table","code":""},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get superclasses of a Wikidata class — superclasses_of","text":"","code":"superclasses_of(\"wd:Q7930989\") #> # A tibble: 3 × 4 #> from to classes classes_label #> #> 1 http://www.wikidata.org/entity/Q17457753 wd:Q7930989 http://www… census subdi… #> 2 http://www.wikidata.org/entity/Q486972 wd:Q7930989 http://www… human settle… #> 3 http://www.wikidata.org/entity/Q3257686 wd:Q7930989 http://www… locality"},{"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","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, 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":"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”: 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:","code":"test_LV=spq_init(\"hal\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% # récupère les personnes appelées \"Lise Vaudor\" spq_perform() DT::datatable(test_LV) requete = spq_init(\"hal\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?personne foaf:interest ?interet\") %>% # récupère les centres d'intérêt spq_add(\"?interet skos:prefLabel ?interet_label\") %>% # étiquette les centres d'intérêt spq_filter(lang(interet_label) == 'fr') 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.","code":"requete = spq_init(\"hal\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% # documents crées par créateur spq_add(\"?createur hal:structure ?affil\") %>% # créateur correspond à une affiliation spq_add(\"?createur hal:person ?personne\") %>% # créateur correspond à une personne spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?affil skos:prefLabel ?affiliation\") %>% # é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 ?affil. ## ?createur hal:person ?personne. ## ?personne foaf:name 'Lise Vaudor'. ## ?affil skos:prefLabel ?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 104. Voici les 20 documents les plus récents:","code":"docs_LV = spq_init(endpoint = \"hal\") %>% spq_add(\"?doc dcterms:creator ?createur\") %>% spq_add(\"?createur hal:structure ?affil\") %>% spq_add(\"?createur hal:person ?personne\") %>% spq_add(\"?personne foaf:name 'Lise Vaudor'\") %>% spq_add(\"?affil skos:prefLabel ?affiliation\") %>% spq_add(\"?doc dcterms:type ?type\") %>% spq_add(\"?type skos:prefLabel ?type_label\") %>% spq_filter(lang(type_label) == '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: 104 × 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… ## # ℹ 94 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. 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 (8815). montre ci-dessous les plus récents (à partir de 2020):","code":"labo_EVS = spq_init(endpoint = \"hal\") %>% spq_add(\"?labo skos:prefLabel ?labo_label\") %>% 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… NA ## 2 https://data.archives-ouvertes.fr/revue/115361 Issue 4 of SCS Tr… NA ## 3 https://data.archives-ouvertes.fr/structure/54063 GEVSM NA ## 4 https://data.archives-ouvertes.fr/structure/145345 Environnement Vil… UMR5600 ## 5 https://data.archives-ouvertes.fr/structure/390864 UMR 5600 EVS NA ## 6 https://data.archives-ouvertes.fr/structure/458855 Plateforme ISIG. … NA ## 7 https://data.archives-ouvertes.fr/structure/493368 Environnement Vil… NA ## 8 https://data.archives-ouvertes.fr/structure/516259 UMR CNRS 5600 EVS… NA ## 9 https://data.archives-ouvertes.fr/structure/516301 Environnement Vil… NA ## 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){ lab = paste0(\"<\",lab,\">\") result = spq_init(endpoint = \"hal\") %>% 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_add(\"?doc dcterms:type ?type\") %>% # récupère le type de document spq_add(\"?type skos:prefLabel ?type_label\") %>% # étiquette le type de document spq_filter(lang(type_label) == 'fr') %>% # ... 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\") dim(docs_EVS) ## [1] 8815 6 docs_EVS_show = docs_EVS %>% select(-labo) %>% filter(date >= 2020) %>% unique() %>% select(auteur, date, type, citation, citation) %>% ungroup() ## Adding missing grouping variables: `labo` ## Adding missing grouping variables: `labo`, `labo_label` dim(docs_EVS_show) ## [1] 1299 6 DT::datatable(docs_EVS_show)"},{"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) ## `summarise()` has grouped output by 'date', 'citation'. You can override using ## the `.groups` argument. ggplot(docs_datecitation, aes(x = date, y = n, fill = type)) + geom_bar(stat = \"identity\") + facet_grid(rows = vars(type))"},{"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/count_items.html","id":null,"dir":"Reference","previous_headings":"","what":"Get counts of items directly in classes — count_items","title":"Get counts of items directly in classes — count_items","text":"Get counts items directly classes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get counts of items directly in classes — count_items","text":"","code":"count_items(classes)"},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get counts of items directly in classes — count_items","text":"classes vector wikidata classes","code":""},{"path":"https://lvaudor.github.io/glitter/reference/count_items.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get counts of items directly in classes — count_items","text":"","code":"classes=c(\"wd:Q627272\",\"wd:Q99527517\") count_items(classes) #> Warning: The `.label` argument of `spq_add()` is deprecated as of glitter 0.2.0. #> ℹ Ability to use `.label` will be dropped in next release, use `spq_label()` #> instead. #> ℹ The deprecated feature was likely used in the glitter package. #> Please report the issue at . #> [1] 287 3"},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":null,"dir":"Reference","previous_headings":"","what":"Get description of Wikidata thing — get_description","title":"Get description of Wikidata thing — get_description","text":"Get description Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get description of Wikidata thing — get_description","text":"","code":"get_description(id, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get description of Wikidata thing — get_description","text":"id Wikidata ID, either item (\"Qxxxxx\") property (\"Pxxxxx\"), item . language language description, defaults English (\"en\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_description.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get description of Wikidata thing — get_description","text":"","code":"get_description(\"wd:Q431603\") #> [1] \"groups using advocacy in order to influence public opinion and policy\" get_description(\"wd:Q431603\", language=\"es\") #> [1] \"conjunto de personas organizadas con el fin de actuar conjuntamente en defensa de un interés común\""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get description of Wikidata thing — get_info","title":"Get description of Wikidata thing — get_info","text":"Get description Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get description of Wikidata thing — get_info","text":"","code":"get_info(id, language = \"en\", with_labels = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get description of Wikidata thing — get_info","text":"id Wikidata ID, either item (\"wd:Qxxxxx\") property (\"wd:Pxxxxx\"), item . language language description, defaults English (\"en\") with_labels Whether keep labels (Boolean)","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get description of Wikidata thing — get_info","text":"","code":"get_info(\"wd:Q431603\") #> $label #> [1] \"advocacy group\" #> #> $description #> [1] \"groups using advocacy in order to influence public opinion and policy\" #>"},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Get label of Wikidata thing — get_label","title":"Get label of Wikidata thing — get_label","text":"Get label Wikidata thing","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get label of Wikidata thing — get_label","text":"","code":"get_label(id, language = \"en\")"},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get label of Wikidata thing — get_label","text":"id Wikidata ID, either item (\"Qxxxxx\") property (\"Pxxxxx\"), item . language language label, defaults English (\"en\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get label of Wikidata thing — get_label","text":"","code":"get_label(\"wd:Q431603\") #> [1] \"advocacy group\" get_label(\"wd:Q431603\", language=\"fr\") #> [1] \"groupe de défense d'intérêts\""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"Get Wikidata item property Get unformatted info Wikidata based item property id.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"","code":"get_thing(id)"},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"id Wikidata ID, either item (\"wd:Qxxxxx\") property (\"wd:Pxxxxx\")","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_thing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Wikidata item or property\nGet unformatted info from Wikidata based on an item or property id. — get_thing","text":"","code":"get_thing(\"wd:Q431603\") #> #> \tWikidata item Q431603 #> #> Label:\t\t advocacy group \t[63 other languages available] #> Aliases:\t 利益集团, 利益團體, 壓力團體, 倡仪团体, קבוצות אינטרס, קבוצות בעלי עניין, קבוצת בעלי עניין, קבוצת לחץ, 압력단체, Grupo de presion, Grupos de presión, Grupos de presion, grupo de interes, Surverühm, Huvigrupp, Kepentingan kelompok, Interessensvertretung, Interessensgruppen, Pressure Group, Interessensgruppe, Interessengruppe, Interessenvereinigung, Lobbyorganisation, 利益集団, インタレストグループ, 圧力団体, ロビー団体, プレッシャーグループ, 特別利益団体, λόμπι, ομάδα ειδικού ενδιαφέροντος, Grupa za pritisak, pressiegroep, belangenvereniging, группа давления, группы интересов, лоббистская организация, лоббирующая организация, Интересне групе, baskı grupları, lobici gruplar, savunma grubu, ilginç grup, özel ilgi grubu, lobi organizasyonu, savunuculuk organizasyonu, kulis, lobi grubu, baskı grubu, baskı organizasyonu, baskı örgütü, özel ilgi organizasyonu, گروه فشار, گروه ذی نفوذ, گروه ذینفوذ, Interesseorganisasjoner, Interessegruppe, Interesseforening, interest group, special interest group, lobbying organization, lobby group, advocacy organization, lobbying group, lobbyists, SIG, lobbying organisation, advocacy organisation, special interest organization, special interest organisation, pressure group, pressure organization, pressure organisation, activist organization, activist group, interest organization, groupe de défense, ініцыятыўная група, lobby, lobbyorganisation, kumpulan pengutara, kumpulan penyokong, kumpulan perakuan, kumpulan sokongan, kumpulan pengutaraan, kumpulan anjuran, edunvalvontajärjestö, etujärjestö, ინტერესთა ჯგუფი, intressegrupp, grup d'interès, grup de pressió, lobistična skupina, адвокаційна група, grup de lobby #> Description: groups using advocacy in order to influence public opinion and policy \t[17 other languages available] #> Claims:\t\t 27 #> Sitelinks:\t 45"},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":null,"dir":"Reference","previous_headings":"","what":"Get triple with subject verb object. — get_triple","title":"Get triple with subject verb object. — get_triple","text":"Get triple subject verb object.","code":""},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get triple with subject verb object. — get_triple","text":"","code":"get_triple( triple = NULL, subject = NULL, verb = NULL, object = NULL, required = TRUE, label = NA, limit = NULL, within_box = c(NA, NA), within_distance = c(NA, NA) )"},{"path":"https://lvaudor.github.io/glitter/reference/get_triple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get triple with subject verb object. — get_triple","text":"triple triple 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\")) required whether require triple (Boolean) label vector variables include label column (defaults NA) limit max number items sent back 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/get_triple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get triple with subject verb object. — get_triple","text":"","code":"get_triple(s = \"wd:Q456\", v = \"wdt:P625\", o = \"?coords\") #> # A tibble: 1 × 1 #> coords #> #> 1 Point(4.841388888 45.758888888) get_triple(t = \"wd:Q456 wdt:P625 ?coords\") #> # A tibble: 1 × 1 #> coords #> #> 1 Point(4.841388888 45.758888888)"},{"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_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\")) )"},{"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()","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":"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/subclasses_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Get subclasses of a Wikidata class — subclasses_of","title":"Get subclasses of a Wikidata class — subclasses_of","text":"Get subclasses Wikidata class","code":""},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get subclasses of a Wikidata class — subclasses_of","text":"","code":"subclasses_of(id, include_self = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get subclasses of a Wikidata class — subclasses_of","text":"id id class include_self whether include class results table","code":""},{"path":"https://lvaudor.github.io/glitter/reference/subclasses_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get subclasses of a Wikidata class — subclasses_of","text":"","code":"subclasses_of(\"wd:Q7930989\") #> # A tibble: 38 × 4 #> from to classes classes_label #> #> 1 wd:Q7930989 http://www.wikidata.org/entity/Q515 http://www… city #> 2 wd:Q7930989 http://www.wikidata.org/entity/Q3957 http://www… town #> 3 wd:Q7930989 http://www.wikidata.org/entity/Q123601 http://www… cities and t… #> 4 wd:Q7930989 http://www.wikidata.org/entity/Q159438 http://www… Hero City of… #> 5 wd:Q7930989 http://www.wikidata.org/entity/Q174844 http://www… megacity #> 6 wd:Q7930989 http://www.wikidata.org/entity/Q188509 http://www… suburb #> 7 wd:Q7930989 http://www.wikidata.org/entity/Q1392581 http://www… cycling city #> 8 wd:Q7930989 http://www.wikidata.org/entity/Q2035733 http://www… Ecumenopolis #> 9 wd:Q7930989 http://www.wikidata.org/entity/Q692581 http://www… holy city #> 10 wd:Q7930989 http://www.wikidata.org/entity/Q853252 http://www… mining town #> # ℹ 28 more rows"},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":null,"dir":"Reference","previous_headings":"","what":"Get superclasses of a Wikidata class — superclasses_of","title":"Get superclasses of a Wikidata class — superclasses_of","text":"Get superclasses Wikidata class","code":""},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get superclasses of a Wikidata class — superclasses_of","text":"","code":"superclasses_of(id, include_self = FALSE)"},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get superclasses of a Wikidata class — superclasses_of","text":"id id class include_self whether include class results table","code":""},{"path":"https://lvaudor.github.io/glitter/reference/superclasses_of.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get superclasses of a Wikidata class — superclasses_of","text":"","code":"superclasses_of(\"wd:Q7930989\") #> # A tibble: 3 × 4 #> from to classes classes_label #> #> 1 http://www.wikidata.org/entity/Q17457753 wd:Q7930989 http://www… census subdi… #> 2 http://www.wikidata.org/entity/Q486972 wd:Q7930989 http://www… human settle… #> 3 http://www.wikidata.org/entity/Q3257686 wd:Q7930989 http://www… locality"},{"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","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":""}]