Getting Started with the OpenAppBuilder Package

Introduction

This vignette provides an overview of the openappr package and demonstrates how to use its functions to interact with OpenAppBuilder to get your App Data into R.

Setting Up the Connection

Before retrieving data, you must establish a connection to your OpenAppBuilder (PostgreSQL) database using the set_app_connection() function:

library(openappr)

set_app_connection(
  dbname = "vmc",
  host = "apps-server.idems.international",
  port = 5432,
  user = "vmc",
  password = "LSQkyYg5KzL747"
)

C:2600ea470a3-to-openappr.R

Once the connection is established, you can retrieve it at any time using the get_app_connection() function:

con <- get_app_connection()

C:2600ea470a3-to-openappr.R

User and Notification Data Retrieval

For specific user data, use the get_user_data() function:

# Retrieve user data filtered by user ID
valid_ids <- c("3e68fcda-d4cd-400e-8b12-6ddfabced348", "223925c7-443a-411c-aa2a-a394f991dd52")
data_filtered_users <- get_openapp_data(
  name = "app_users",
  filter = TRUE,
  filter_variable = "app_user_id",
  filter_variable_value = valid_ids
)

C:2600ea470a3-to-openappr.R

Similarly, the get_nf_data() function allows you to retrieve and process notification interaction data:

# Retrieve filtered notification interaction data
filtered_notification_data <- get_nf_data(
  filter = TRUE,
  filter_variable = "app_user_id",
  filter_variable_value = valid_ids
)

C:2600ea470a3-to-openappr.R

Retrieving General Data

The get_openapp_data() function allows you to retrieve data from the specified tables or execute a custom SQL query.

# Retrieve all data from the 'app_users' table
data_all_users <- get_openapp_data()

# Retrieve filtered data from the 'app_users' table
valid_ids <- c("3e68fcda-d4cd-400e-8b12-6ddfabced348", "223925c7-443a-411c-aa2a-a394f991dd52")
data_filtered_notifications <- get_openapp_data(
  name = "app_users",
  filter = TRUE,
  filter_variable = "app_user_id",
  filter_variable_value = valid_ids
)

C:2600ea470a3-to-openappr.R

Conclusion

The openappr package provides a convenient way to connect to OpenAppBuilder and retrieve data, customise your queries, and filter to suit your data needs.