4 Installation

Discoveryengine (and all packages we use in Prospect Developmemt) is installed on the R drive. The most important step to make sure you can access these packages is to set up your default library path to the shared packages repository.

Run a quick test to see your current library path:

.libPaths()

The first result returned shoud be “\\\\ur2.urel.berkeley.edu/ur_unitshares/Prospect Development/Prospect Analysis/pd-shared-r-packages”. If it’s not, follow the steps below to change your default library path.

Step 1: Open a new RStudio session and run the following script:

# the first part sets up the new package directory
package_dir <- "\\\\ur2.urel.berkeley.edu/ur_unitshares/Prospect Development/Prospect Analysis/pd-shared-r-packages"
if (!dir.exists(package_dir)) dir.create(package_dir, recursive = TRUE)

# then make a configuration file that notifies R of the new package directory
# change [username] to your actual username in your P drive - usually your last name followed by your first initial
if (!file.exists(env_file)) file.create(env_file)
env_file <- "\\ur2.urel.berkeley.edu\UR_USERS\[username]"

# and add the new location to the configuration file
cat("\nR_LIBS_USER='", package_dir, "'", 
    sep = "", file = env_file, append = TRUE)

Step 2:

Quit your current RStudio session and open a new one. Try running the following test again:

.libPaths()

If the PD shared packages depository is returned, you are ready to start using Disco Engine. If not, contact the Analytics Team to troubleshoot your situation.

4.1 Before you continue

At this point, you should have already: - tested your CDW connection - installed getcdw - run a test query

If you haven’t completed all of those items, head over to section Test CDW and complete those steps, and then return here.

4.2 A disco test

In order to make sure everything is working properly, we’ll run a quick disco test:

# you'll always load the discoveryengine package before doing anythying else
library(discoveryengine)
# make sure we can create a disco definition
high_cap = has_capacity(1)
# make sure that things print properly
high_cap
## LISTBUILDER DEFINITION (type: entity_id)
## .   source: d_entity_mv.entity_id (entity_id)
## .   logic: capacity_rating_code IN (1)
# make sure we can send the defintion to the data warehouse
display(high_cap)
## # A tibble: 298 x 1
##    entity_id
##        <dbl>
##  1      1969
##  2      3105
##  3      3422
##  4      7011
##  5      7644
##  6     12178
##  7     12453
##  8     17464
##  9     18139
## 10     20125
## # … with 288 more rows

If you got this far without any problems, then congrats! You are a disco dancer!