Reference - Maple Help

DataSets[Builtin]

 Reference
 create a reference to built-in data

 Calling Sequence Reference(id) DataSets:-Reference("Builtin", id) ref := Reference(id) ref[rows] ref[rows, columns] ref[boolexps] ref[boolexps, columns]

Parameters

 id - string; identifier of the data set, which can be either Country or GeoNames rows - row index or list of row indices, where each row index is a string, range, or integer columns - column index or list of column indices, where each column index is a string, name, range, or integer boolexps - boolean expression or list of boolean expressions

Description

 • The Reference command creates a reference to a built-in data set (that is, a country or city data set that comes with Maple).
 • The reference object retrieves data only when necessary, and caches data retrieved from non-local sources.
 • Reference objects can be created without this command with DataSets[Search] or DataSets[InsertSearchBox].
 • Time series data, including Quandl references, inside a built-in data reference will be displayed in a condensed form, showing only that it is a time series and its newest value. Other data types are displayed as normal.

Indexing

 • A reference object ref can be indexed to get a new reference representing a subset of the data, or just one entry in the data set.
 – A single entry from the data set is returned if and only if the row index is a string or integer, and the column index is a string, name, or integer.
 – Every other calling sequence will return a reference object.
 • Rows indices strings, integers, or ranges.
 – A string will select the row whose name equals that string. Row names are always unique within a data set.
 – Integers and ranges work similarly to indexing a Matrix, where positive integers or endpoints start at the first row and counts up to later rows, and negative integers or endpoints start at the last row and counts down to earlier rows.
 – Missing start and end endpoints in a range will be interpreted as $1$ and $-1$, respectively.
 – The ordering of the rows is not guaranteed. So using integers or ranges may not always select the same rows, even if two references contains the same set of rows.
 – Multiple row indices may be combined with a list to select the union of the rows selected by the individual indices. But note that selecting the same row more than once will result in an error.
 • Columns indices are strings, names, integers, or ranges.
 – A string or name will select the column whose name equals that string or name converted to a string. Column names are always unique within a data set.
 – The first column, which uniquely identifies each row, will remain the first column even if it does not appear among the indices. If the first column exists among the indices, it must be the first one.
 – Integers and ranges start from the second column, but otherwise works the same way as row indices. The first column cannot be selected with integers or ranges.
 – The ordering of the columns is not guaranteed except the row name column, which will always be the first column.
 – Multiple column indices may also be combined in the same way as row indices, and selecting the same column more than once will result in an error.
 – The first column in the Country data set is always the Name column, and the first column in the GeoNames data set is always the GeoNamesid column.
 • A second method to select rows is to filter by the values in the rows with a boolean expression or a list of boolean expressions.
 – The indeterminants in each boolean expression must be the names of the columns, as Maple names.
 – For each row, the indeterminants are substituted for the value at the corresponding column and at that row. If the boolean expression or the conjunction of the list of boolean expressions is satisfied, then that row is retained. Otherwise, that row is removed.
 – The newest value will be used for time series data. Other data are used normally.
 • Indexing can take a long time if the resulting data set contains a large number of rows.

Examples

 > $\mathrm{with}\left(\mathrm{DataSets}\right):$

Create a reference to a data set with all the countries in the world.

 > $\mathrm{ref}≔\mathrm{Reference}\left("Builtin","Country"\right)$
 ${\mathrm{ref}}{≔}\left[\begin{array}{ccccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CO2 Emissions}}& {\mathrm{CPI Change}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {\mathrm{\left(124 more\right)}}\\ {\mathrm{Afghanistan}}& {\mathrm{TimeSeries 9809.225}}& {\mathrm{TimeSeries 4.9759515055383}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Albania}}& {\mathrm{TimeSeries 5716.853}}& {\mathrm{TimeSeries 1.41109078954244}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Algeria}}& {\mathrm{TimeSeries 145400.217}}& {\mathrm{TimeSeries 1.95176821052894}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\ddots }\right]\right)& {}\\ {\mathrm{\left(182 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (1)

Create the same reference with a different calling sequence.

 > $\mathrm{Builtin}:-\mathrm{Reference}\left("Country"\right)$
 $\left[\begin{array}{ccccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CO2 Emissions}}& {\mathrm{CPI Change}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {\mathrm{\left(124 more\right)}}\\ {\mathrm{Afghanistan}}& {\mathrm{TimeSeries 9809.225}}& {\mathrm{TimeSeries 4.9759515055383}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Albania}}& {\mathrm{TimeSeries 5716.853}}& {\mathrm{TimeSeries 1.41109078954244}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Algeria}}& {\mathrm{TimeSeries 145400.217}}& {\mathrm{TimeSeries 1.95176821052894}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\ddots }\right]\right)& {}\\ {\mathrm{\left(182 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (2)

Select a subset of the data with the index operator.

 > $\mathrm{ref}\left[2..4,2..4\right]$
 $\left[\begin{array}{cccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CPI Change}}& {\mathrm{Child Mortality}}& {\mathrm{Currency Code}}\\ {\mathrm{Albania}}& {\mathrm{TimeSeries 1.41109078954244}}& {\mathrm{TimeSeries 8.8}}& {"ALL"}\\ {\mathrm{Algeria}}& {\mathrm{TimeSeries 1.95176821052894}}& {\mathrm{TimeSeries 23.5}}& {"DZD"}\\ {\mathrm{Angola}}& {\mathrm{TimeSeries 17.1453199427872}}& {\mathrm{TimeSeries 77.2}}& {"AOA"}\end{array}\right]$ (3)
 > $\mathrm{ref}\left["Canada",\left[1,3\right]\right]$
 $\left[\begin{array}{ccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CO2 Emissions}}& {\mathrm{Child Mortality}}\\ {\mathrm{Canada}}& {\mathrm{TimeSeries 537193.498}}& {\mathrm{TimeSeries 5.0}}\end{array}\right]$ (4)
 > $\mathrm{ref}\left[\left["USA",5\right],\left[1,3..4\right]\right]$
 $\left[\begin{array}{cccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CO2 Emissions}}& {\mathrm{Child Mortality}}& {\mathrm{Currency Code}}\\ {\mathrm{Antigua and Barbuda}}& {\mathrm{TimeSeries 531.715}}& {\mathrm{TimeSeries 6.4}}& {"XCD"}\\ {\mathrm{USA}}& {\mathrm{TimeSeries 5254279.285}}& {\mathrm{TimeSeries 6.5}}& {\mathrm{undefined}}\end{array}\right]$ (5)

Select just one entry in the data set.

 > $\mathrm{ref}\left["Canada",\mathrm{CPI Change}\right]$
 $\left[\begin{array}{cc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CPI Change}}\\ {\mathrm{Canada}}& {\mathrm{TimeSeries 1.94926902411596}}\end{array}\right]$ (6)
 > $\mathrm{ref}\left[2,4\right]$
 ${"ALL"}$ (7)

Convert to a Matrix.

 > $\mathrm{convert}\left(\mathrm{ref}\left["Canada",\left[1,3\right]\right],'\mathrm{Matrix}'\right)$
 $\left[\begin{array}{ccc}{"Canada"}& \left[\begin{array}{c}{\mathrm{Data set}}\\ {\mathrm{CO2 emissions \left(kt\right) - Canada}}\\ {\mathrm{Quandl WWDI/CAN_EN_ATM_CO2E_KT}}\\ {\mathrm{up to 65 rows \left(annual\right), 1 column}}\\ {\mathrm{1950-12-31 - 2014-12-31}}\end{array}\right]& \left[\begin{array}{c}{\mathrm{Data set}}\\ {\mathrm{Mortality rate, under-5 \left(per 1,000 live births\right) - Canada}}\\ {\mathrm{Quandl WWDI/CAN_SH_DYN_MORT}}\\ {\mathrm{up to 69 rows \left(annual\right), 1 column}}\\ {\mathrm{1950-12-31 - 2018-12-31}}\end{array}\right]\end{array}\right]$ (8)

Using boolean expressions to filter.

 > $\mathrm{ref2}≔\mathrm{ref}\left[1..5,\left["CPI Change","CO2 Emissions"\right]\right]$
 ${\mathrm{ref2}}{≔}\left[\begin{array}{ccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CPI Change}}& {\mathrm{CO2 Emissions}}\\ {\mathrm{Afghanistan}}& {\mathrm{TimeSeries 4.9759515055383}}& {\mathrm{TimeSeries 9809.225}}\\ {\mathrm{Albania}}& {\mathrm{TimeSeries 1.41109078954244}}& {\mathrm{TimeSeries 5716.853}}\\ {\mathrm{Algeria}}& {\mathrm{TimeSeries 1.95176821052894}}& {\mathrm{TimeSeries 145400.217}}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)\\ {\mathrm{\left(2 more\right)}}& {}& {}\end{array}\right]$ (9)
 > $\mathrm{ref2}\left[5000<\mathrm{CO2 Emissions}\right]$
 $\left[\begin{array}{ccc}{\mathrm{Country \left(Name\right)}}& {\mathrm{CPI Change}}& {\mathrm{CO2 Emissions}}\\ {\mathrm{Afghanistan}}& {\mathrm{TimeSeries 4.9759515055383}}& {\mathrm{TimeSeries 9809.225}}\\ {\mathrm{Albania}}& {\mathrm{TimeSeries 1.41109078954244}}& {\mathrm{TimeSeries 5716.853}}\\ {\mathrm{Algeria}}& {\mathrm{TimeSeries 1.95176821052894}}& {\mathrm{TimeSeries 145400.217}}\\ {\mathrm{Angola}}& {\mathrm{TimeSeries 17.1453199427872}}& {\mathrm{TimeSeries 34763.16}}\end{array}\right]$ (10)

Create a reference to the GeoNames data set.

 > $\mathrm{refg}≔\mathrm{Builtin}:-\mathrm{Reference}\left("Geonames"\right)$
 ${\mathrm{refg}}{≔}\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {\mathrm{\left(7 more\right)}}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{68}}\right]\right)& {\mathrm{Boneh-ye Mehdi}}& {"section of populated place"}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{121}}\right]\right)& {\mathrm{Lab Sefid}}& {"locality"}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{166}}\right]\right)& {\mathrm{Gorizi}}& {"locality"}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{⋮}\right]\right)& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\ddots }\right]\right)& {}\\ {\mathrm{\left(1155858 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (11)

 > $\mathrm{refg}\left[\left[\mathrm{Country}="Canada",\mathrm{Type}="populated place",1000<\mathrm{Population},\mathrm{Name}="Waterloo"\right]\right]$
 $\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {\mathrm{\left(7 more\right)}}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{6176821}}\right]\right)& {\mathrm{Waterloo}}& {"populated place"}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\\ {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{6176823}}\right]\right)& {\mathrm{Waterloo}}& {"populated place"}& {\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\dots }\right]\right)& {}\end{array}\right]$ (12)