JavaScript in Displayr - Displayr https://www.displayr.com/category/r/javascript-in-displayr/ Displayr is the only BI tool for survey data. Mon, 23 Nov 2020 20:44:29 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.2 https://www.displayr.com/wp-content/uploads/2023/10/cropped-Displayr-Favicon-Dark-Bluev2-32x32.png JavaScript in Displayr - Displayr https://www.displayr.com/category/r/javascript-in-displayr/ 32 32 Using the API to Create a Regression and Save Values as a JavaScript Variable https://www.displayr.com/using-the-api-to-create-a-regression-and-save-values-as-a-javascript-variable/?utm_medium=Feed&utm_source=Syndication https://www.displayr.com/using-the-api-to-create-a-regression-and-save-values-as-a-javascript-variable/#respond Wed, 10 Apr 2019 06:43:55 +0000 https://www.displayr.com/?p=17069 ...]]> Step 1: Do everything in Getting Started with the Displayr API

Once you have done this, open up the document and it should look like this:

Step 2: Obtain the Document secret

To modify a document using the API we need to know its Document secret. This is found by following these steps:

  1. Go to the document's settings page (if in the document, click on the cog at the top right of the screen and press Document Settings)
  2. Expand out the Properties section.
  3. The document secret is located in the bottom-right corner.

Step 3: Download the regression.zip file

  1. Click here to download the zip file
  2. Double-click on it to open it
  3. Save its contents somewhere on your computer or network

The zip file contains:

  • A file called regression.QScript which contains a QScript for running the regression and creating a new variable with the predicted values
  • A file called regression.py which contains a Python script for running the QScript

Step 2: Edit and run the regression.py file

  1. Open the file in a text editor
  2. On line 20, replace insert-document-secret with the document secret (as described above)
  3. Save the file
  4. Run the regression.py script using the process in Step 6 of Getting Started with the Displayr API
  5. Check out the regression model (it has been added as a new page in your document) and the variable at the top of the list under Data Sets contains the predicted values from the model.
]]>
https://www.displayr.com/using-the-api-to-create-a-regression-and-save-values-as-a-javascript-variable/feed/ 0