The features in Automatically Combine Categories > World are use to transform either Latitude/longitude coordinates or IP adresses into the geographic locations that correspond to this data. Such data can be transformed to the Country in which they are located, or the State or Province in which they are located.
Example
In this example, latitude and longitude coordinates have been transformed into the states in which they are located:
Usage
In Q:
- Select a pair of latitude/longitude variables, or a single variable of IP addresses in the Variables and Questions tab.
- Select the desired option from Automate > Browse Online Library > Create New Variables > Automatically Combine Categories > By Geography > World > To States/Provinces.
- To change how the categories are combined:
- Select the new variable or question in the Variables and Questions tab.
- Right-click and select Edit R Variable.
- Choose the desired options in the Inputs section on the right.
- Click Update R Variable.
In Displayr:
- Select a pair of latitude/longitude variables, or a single variable of IP addresses in the Data Sources tree and click + > Combine Categories > By Geography > World > To States/Provinces.
- To change how categories are combined (for example, you might decide that the counties aren't very useful and you would prefer regions instead):
- Select the new variable you created from the Data Sources tree.
- In Object Inspector, update Data > Output geographic type.
How to apply this QScript
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Click on the QScript when it appears in the QScripts and Rules section of the search results.
OR
- Select Automate > Browse Online Library.
- Select this QScript from the list.
Customizing the QScript
This QScript is written in JavaScript and can be customized by copying and modifying the JavaScript.
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Hover your mouse over the QScript when it appears in the QScripts and Rules section of the search results.
- Press Edit a Copy (bottom-left corner of the preview).
- Modify the JavaScript (see QScripts for more details on this).
- Either:
- Run the QScript, by pressing the blue triangle button.
- Save the QScript and run it at a later time, using Automate > Run QScript (Macro) from File.
See also
- QScript for more general information about QScripts.
- QScript Examples Library for other examples.
- Online JavaScript Libraries for the libraries of functions that can be used when writing QScripts.
- QScript Reference for information about how QScript can manipulate the different elements of a project.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.