DataSets[Builtin]
Reference
create a reference to built-in data
Calling Sequence
Parameters
Description
Indexing
Examples
Compatibility
Reference(id)
DataSets:-Reference("Builtin", id)
ref := Reference(id)
ref[rows]
ref[rows, columns]
ref[boolexps]
ref[boolexps, columns]
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
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].
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.
with⁡DataSets:
Create a reference to a data set with all the countries in the world.
ref≔Reference⁡Builtin,Country
ref≔Country (Name)Currency Code2 Letter Country Code…(57 more)AfghanistanAFNAF…AlbaniaALLAL…AlgeriaDZDDZ…⋮⋮⋮⋱(182 more)
Create the same reference with a different calling sequence.
Builtin:-Reference⁡Country
Country (Name)Currency Code2 Letter Country Code…(57 more)AfghanistanAFNAF…AlbaniaALLAL…AlgeriaDZDDZ…⋮⋮⋮⋱(182 more)
Select a subset of the data with the index operator.
ref2..4,2..4
Country (Name)2 Letter Country CodeCountry Code for Internet Top-Level Domain3 Letter Country CodeAlbaniaALalALBAlgeriaDZdzDZAAngolaAOaoAGO
refCanada,1,3
Country (Name)Currency CodeCountry Code for Internet Top-Level DomainCanadaCADca
refUSA,5,1,3..4
Country (Name)Currency CodeCountry Code for Internet Top-Level Domain3 Letter Country CodeAntigua and BarbudaXCDagATGUSAundefinedusUSA
Select just one entry in the data set.
refCanada,`Irrigated land`
Country (Name)Irrigated landCanada8699.⁢km2
ref2,4
ALB
Convert to a Matrix.
convert⁡refCanada,1,3,Matrix
CanadaCADca
Using boolean expressions to filter.
ref2≔ref1..10,Obesity - adult prevalence rate (%),Electricity - from hydroelectric plants (%)
ref2≔Country (Name)Obesity - adult prevalence rate (%)Electricity - from hydroelectric plants (%)Afghanistan2.2000076.5000Albania21.300094.4000Algeria162.50000⋮⋮⋮(7 more)
ref220<`Obesity - adult prevalence rate (%)`
Country (Name)Obesity - adult prevalence rate (%)Electricity - from hydroelectric plants (%)Albania21.300094.4000Antigua and Barbuda25.60000Argentina29.700027.6000⋮⋮⋮(4 more)
Create a reference to the GeoNames data set.
refg≔Builtin:-Reference⁡Geonames
refg≔Geonames (GeoNamesid)NameType…(7 more)68Boneh-ye Mehdisection of populated place…121Lab Sefidlocality…166Gorizilocality…⋮⋮⋮⋱(1155858 more)
Search for Waterloo in Canada.
refgCountry=Canada,Type=populated place,1000<Population,Name=Waterloo
Geonames (GeoNamesid)NameType…(7 more)6176821Waterloopopulated place…6176823Waterloopopulated place…
The DataSets[Builtin][Reference] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
DataSets[Reference]
Download Help Document