The-Strategy-Unit / nhp_evidence_maps

Shiny app: NHP evidence map
https://connect.strategyunitwm.nhs.uk/nhp_evidence_map/
Other
1 stars 0 forks source link

Host the data on Connect and read it in #48

Closed matt-dray closed 4 months ago

matt-dray commented 6 months ago

Only necessary when v0.1.0 is released and published. Related to #46 and #47.

matt-dray commented 6 months ago

Probably supersedes #15.

matt-dray commented 4 months ago

{pins} seems a good option for now.

Rhian has pinned a dummy dataset and Quarto doc on Connect (with selected edit and view permissions). The doc reads from the pinned data set like:

board <- pins::board_connect()
animal_crossing_villagers <- pins::pin_read(board, "rhian.davies/animal_crossing_villagers")

Writing/overwriting the pin would be like board |> pins::pin_write().

matt-dray commented 4 months ago

A more bespoke example (untested):

# Create a list, each element is a sheet from the Excel file

xlsx_path <- file.path("data", "file.xlsx")
sheet_names <- readxl::excel_sheets(xlsx_path)

evidence_map_list <- vector("list", length(sheet_names)) |> 
  purrr::set_names(sheet_names)

for (sheet_name in sheet_names) {
  evidence_map_list[[sheet_name]] <- readxl::read_xlsx(xlsx_path, sheet_name)
}

# Write the list object as a pin to the board 

board <- pins::board_connect()

board |> 
  pins::pin_write(
    x = evidence_map_list, 
    name = "nhp_evidence_map",  # how to refer to the pin
    type = "rds"
  )

pins::pin_browse(board, "matt.dray/nhp_evidence_map")  # view in browser

pins::pin_read(board, "matt.dray/nhp_evidence_map")
matt-dray commented 4 months ago

Closed with #65.