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 adresses 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 the variable you want to aggregate (for example, postcode) and click the plus sign
to the right of the variable
- From the Insert Variable(s) menu, select Ready Made New Variables > Automatically 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 Sets tree
- In Object Inspector, select Inputs > Automatically Combine Categories > Output geographic type menu,
- Change the selection to option.
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.
Customizing QScripts in Q4.11 and more recent versions
- 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 detail 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.
Customizing QScripts in older versions
- Contact support@q-researchsoftware.com to obtain a copy of the JavaScript code.
- Create a new text file, giving it a file extension of .QScript. See here for more information about how to do this.
- Modify the JavaScript (see QScripts for more detail on this).
- Run the file 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.