This article describes how to remove a category from a variable set without rebasing it. This is automating the process of right-clicking on a category in a table and selecting Hide.
Requirements
A Displayr Enterprise user license which includes the ability to add custom analysis menu items and QScripts. See How to Use QScripts in Displayr for more details.
Please note these steps require a Displayr license.
Method
To run the QScript to unhide all variable sets in the document:
- From the toolbar menu, select Anything > [Your account name] > Open QScript Editor.
- Paste the following code into the QScript editor:
var age = project.dataFiles[0].getQuestionByName('Age'); age.dataReduction.hide("Don't know");
- Click the Play button in the QScript Editor toolbar to run the QScript:
- If you want to save the QScript for future use, click OK then enter a file name for the QScript and click OK. This will save the QScript to your Displayr cloud drive and will then be available in all of your documents by selecting Anything > [Your account name] > Open QScript from Displayr Cloud Drive > [QScript Name]. If you don't wish to save the QScript to the cloud drive, click Cancel in the QScript Editor.
The first line of code above finds a question named 'Age' in the first data file (note that [0] finds the first data file, [1] would find the second, etc. ) and assigns it to a variable called age.
The second line of the code modifies the variable age. It does so using the question’s Data Reduction which is the object that stores which categories have been merged together, which have been hidden, what their names are and what order they are shown in. Thus, the hide instruction is hiding the Don’t know category and this will cause the category not to appear when this question is used to create tables and charts.
Next
How to Hide/Unhide Variables Sets Selected from a List
How to Hide/Unhide Questions with Many Categories
How to Unhide All Hidden Questions
How to Use QScripts in Displayr
How to Create a Custom QScript