From 9bcfaa1d518d0bb5cfaafbdbbcd30025092c56b2 Mon Sep 17 00:00:00 2001 From: Evanstats Date: Tue, 16 Apr 2024 09:33:07 +0300 Subject: [PATCH] Dashboard updates - 15/04/2024 --- .../DC486B7A/pcs/windowlayoutstate.pper | 14 ++ .Rproj.user/DC486B7A/sources/prop/56D2A599 | 6 + .Rproj.user/DC486B7A/sources/prop/7A1F73DB | 6 + .Rproj.user/DC486B7A/sources/prop/DC8F4729 | 6 + .../session-6291cfb0/119FC69B-contents | 71 ++++++++++ .../session-6291cfb0/205BB7E0-contents | 131 ++++++++++++++++++ .../session-6291cfb0/5437C517-contents | 38 +++++ .../sources/session-6291cfb0/578901C3 | 26 ++++ .../session-6291cfb0/578901C3-contents | 40 ++++++ .../session-6291cfb0/7E27F9C7-contents | 130 +++++++++++++++++ .../session-6291cfb0/EC75C9F7-contents | 5 + .../sources/session-6291cfb0/lock_file | 0 EFM_loading_data.R | 5 +- EFM_shiny.xlsx | Bin 14869 -> 14871 bytes app.R | 1 + 15 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 .Rproj.user/DC486B7A/pcs/windowlayoutstate.pper create mode 100644 .Rproj.user/DC486B7A/sources/prop/56D2A599 create mode 100644 .Rproj.user/DC486B7A/sources/prop/7A1F73DB create mode 100644 .Rproj.user/DC486B7A/sources/prop/DC8F4729 create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/119FC69B-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/205BB7E0-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/5437C517-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3 create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/7E27F9C7-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/EC75C9F7-contents create mode 100644 .Rproj.user/DC486B7A/sources/session-6291cfb0/lock_file diff --git a/.Rproj.user/DC486B7A/pcs/windowlayoutstate.pper b/.Rproj.user/DC486B7A/pcs/windowlayoutstate.pper new file mode 100644 index 0000000..e9bc0d5 --- /dev/null +++ b/.Rproj.user/DC486B7A/pcs/windowlayoutstate.pper @@ -0,0 +1,14 @@ +{ + "left": { + "splitterpos": 300, + "topwindowstate": "NORMAL", + "panelheight": 647, + "windowheight": 685 + }, + "right": { + "splitterpos": 334, + "topwindowstate": "NORMAL", + "panelheight": 647, + "windowheight": 685 + } +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/prop/56D2A599 b/.Rproj.user/DC486B7A/sources/prop/56D2A599 new file mode 100644 index 0000000..fc0b820 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/prop/56D2A599 @@ -0,0 +1,6 @@ +{ + "source_window_id": "", + "Source": "Source", + "cursorPosition": "85,0", + "scrollLine": "76" +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/prop/7A1F73DB b/.Rproj.user/DC486B7A/sources/prop/7A1F73DB new file mode 100644 index 0000000..6743585 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/prop/7A1F73DB @@ -0,0 +1,6 @@ +{ + "source_window_id": "", + "Source": "Source", + "cursorPosition": "118,29", + "scrollLine": "115" +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/prop/DC8F4729 b/.Rproj.user/DC486B7A/sources/prop/DC8F4729 new file mode 100644 index 0000000..186bd29 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/prop/DC8F4729 @@ -0,0 +1,6 @@ +{ + "source_window_id": "", + "Source": "Source", + "cursorPosition": "32,39", + "scrollLine": "24" +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/119FC69B-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/119FC69B-contents new file mode 100644 index 0000000..7472cb4 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/119FC69B-contents @@ -0,0 +1,71 @@ +# Function to call matomo data +calling_matomo_data <- function(date_from = "2023-10-25", date_to = "2024-10-25", data = plhdata_org, + type = c("none", "EFM_KE", "EFM_not_KE"), + token = token_matomo){ + type <- match.arg(type) + + if (type == "EFM_KE"){ + segment_name <- "segment=pageTitle%3D%3DEarly%252520Family%252520Math;countryCode%3D%3Dke" + } else if (type == "EFM_not_KE"){ + segment_name <- "segment=pageTitle%3D%3DEarly%252520Family%252520Math;countryCode!%3Dke" + } else { + segment_name <- "segment=" + } + + json_file <- paste0("https://apps-server.idems.international/analytics/index.php?apiAction=getUsers&apiModule=UserId&date=", date_from, ",", date_to, "&expanded=1&filter_limit=-1&format=JSON&idSite=1&method=API.getProcessedReport&module=API&period=range&", segment_name, "&token_auth=", token) + + json_data <- jsonlite::fromJSON(txt=json_file, flatten = TRUE) + + our_data <- json_data$reportData + names(our_data) <- c("UUID", "Visits", "Actions", "C", "D", "Actions per visit", "Avg. Time on Website", "Bounce Rate") + our_data <- our_data %>% dplyr::select(-c("C", "D")) + our_data$`Bounce proportion` <- as.numeric(as.character(stringr::str_split(our_data$`Bounce Rate`, "%", simplify = TRUE)[,1]))/100 + our_data <- our_data %>% mutate(Bounce = round(`Bounce proportion` * Visits, 0)) %>% dplyr::select(-c("Bounce Rate")) + our_data$`Avg. Time on Website` <- period_to_seconds(hms(x = our_data$`Avg. Time on Website`, format = "%H:%M:%S"))[1:length(our_data$`Avg. Time on Website`)] + our_data$`Time on Website` <- our_data$`Avg. Time on Website` * our_data$Visits # this is calculated so can be out by 10 seconds or so + + valid_uuid <- data[["app_user_id"]] + #data <- data %>% dplyr::select(c(UUID = app_user_id)) + our_data <- our_data %>% filter(UUID %in% valid_uuid) + + return(our_data) +} + + +# Functions +# function to fix up namings to make it a bit prettier! +naming_conventions <- function(x, replace, replace_after) { + if (!missing(replace)){ + x <- gsub(paste("^.*?", replace, ".*", sep = ""), "", x) + } + if (!missing(replace_after)){ + x <- gsub(paste(replace_after, "$", sep = ""), "", x) + } + substr(x, 1, 1) <- toupper(substr(x, 1, 1)) + x <- gsub("_", " ", x) + x +} + +# so we can use "add_na_variable" to add into the data variables which are not in the data +# but will be at some point +# this function checks if the variable is in the data. +# If it is not in the data, then it adds it as a new variable with all NAs. +add_na_variable <- function(data = contacts_unflat, variable){ + for (names in variable) { + if (!names %in% colnames(data)) { + data[, names] <- NA + warning(paste(names, "does not exist. Adding NAs")) + } + } + return(data) +} + +# Function to count dates in each element of the vector +count_dates <- function(x) { + if (is.na(x)) { + return(0) + } else { + dates <- unlist(strsplit(x, ";")) + return(length(dates)) + } +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/205BB7E0-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/205BB7E0-contents new file mode 100644 index 0000000..a02a7c8 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/205BB7E0-contents @@ -0,0 +1,131 @@ +#devtools::install_github("IDEMSInternational/postgresr") +#devtools::install_github("IDEMSInternational/plhR") + +data_l <- import_list("EFM_shiny.xlsx") + +# Download data ---------------------------------------------------------------- +# download EFM app data from Metabase as an RDS file? + +plhdata_org <- postgresr::get_user_data(site = plh_con, filter = FALSE) + +# plhdata_org <- get_user_data(filter_variable = "app_deployment_name", +# filter_variable_value = "early_family_math", +# site = plh_con, merge_check = FALSE, filter = TRUE) +#names(plhdata_org) <- gsub(x = names(plhdata_org), pattern = "\\-", replacement = ".") +#View(plhdata_org) + +mydate <- "2023-12-15" +plhdata_org <- plhdata_org %>% filter(as.Date(createdAt) > as.Date(mydate)) + +# filter to web users? +plhdata_org <- plhdata_org %>% dplyr::filter(nchar(app_user_id) == 16) + +# filter to individuals from Kenya +token_matomo <- read.table("token_matomo", quote="\"", comment.char="") +efm_kenya <- calling_matomo_data(type = "EFM_KE") +kenyan_ids <- efm_kenya$UUID +plhdata_org <- plhdata_org %>% dplyr::filter(app_user_id %in% kenyan_ids) + +# COUNTING the number of clicks -------------------------------------------------------------------- +### Creating counts +#x <- c("2023-11-24T09:28:59 ; 2023-11-24T09:30:22", NA, "2023-11-27T14:45:52") + +# Apply the function to each element of the vector + +# METHOD 1: sapply +# plhdata_org1 <- plhdata_org %>% +# mutate(count_activities_button_click_history = +# sapply(`rp-contact-field.activities_button_click_history`, count_dates)) +# plhdata_org1 %>% dplyr::select(count_activities_button_click_history, `rp-contact-field.activities_button_click_history`) + +# METHOD 2: purrr +# plhdata_org2 <- plhdata_org %>% +# mutate(count_activities_button_click_history_purrr = +# purrr::map_dbl(.x = `rp-contact-field.activities_button_click_history`, +# .f = ~ count_dates(.x))) +# +# plhdata_org2 %>% dplyr::select(count_activities_button_click_history, count_activities_button_click_history_purrr, rp.contact.field.activities_button_click_history) %>% View() +# + +# METHOD 3: multiple columns +plhdata_org <- plhdata_org %>% + mutate(across(ends_with("_click_history"), # put in here a set of variables. + .names = "{.col}_count", # rename the new variables + ~ sapply(.x, count_dates))) # apply count_dates to them. +#plhdata_org_3 %>% View() + + + +######################################### Hello - fixes and comments ####################################### + +# we got an error in shiny: +# Caused by error in `.data[["rp-contact-field.efm_sb_Cat_And_Dog_And_The_Ball_book_click_history"]]`: +# ! Column `rp-contact-field.efm_sb_Cat_And_Dog_And_The_Ball_book_click_history` not found in `.data`. + +# lets check if these variables exist + +vars_to_check <- data_l$storybooks$variable +plhdata_org <- add_na_variable(data = plhdata_org, variable = vars_to_check) + +# WARNING: Please please check when you do this - this code creates the variable and fills with NAs if it +# is not in the data set. +# However, it may be that this variable is a typo, and so therefore you need to check the typo and fix it that way. +# Please make sure of this. I've noticed some typos already - e.g. you said +# app_last_launch, not rp-contact-field.app_last_launch. I've fixed this on run_plhr_shiny.R + +#### Fix namings for rp-contact-field.current_book +# We just want to remove "data.efm_storybooks.efm_sb_" from our names +plhdata_org$`rp-contact-field.current_book` <- naming_conventions(plhdata_org$`rp-contact-field.current_book`, + "data.efm_storybooks.efm_sb_") + + +#TODO: remove data column in spreadsheet +plhdata_org$`rp-contact-field._server_sync_latest` <- lubridate::as_date(plhdata_org$`rp-contact-field._server_sync_latest`) +plhdata_org$`app_last_launch` <- plhdata_org$`rp-contact-field.app_last_launch` +plhdata_org$`app_launch_count` <- plhdata_org$`rp-contact-field.app_launch_count` + +#App last sync +plhdata_org <- plhdata_org %>% + mutate(synced_7_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 7, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_7_14_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 14 & + `rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 7, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_14_30_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 30 & + `rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 14, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_more_than_30_days = ifelse(`rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 30, + 1,0)) + +plhdata_org$app_last_launch <- as.Date(plhdata_org$app_last_launch) + +# # App last launch - line graph +# plhdata_org$app_last_launch <- as.Date(plhdata_org$app_last_launch) +# +# # Creating a data frame of the last lauched dates +# app_last_launch_data <- plhdata_org %>% +# filter(!is.na(app_last_launch)) %>% +# group_by(app_last_launch) %>% +# summarise(frequency = n()) + +# Creating the line graph +# ggplot(app_last_launch_data) + +# geom_line(aes(x = app_last_launch, y = frequency)) + +# geom_point(aes(x = app_last_launch, y = frequency)) + +# labs(x = "Date", y = "Frequency", title = "Frequency of Values by Date") +# + + +# 15/04/2024 - Evans removed "App Launch History" from demographics tab. + + + + + + diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/5437C517-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/5437C517-contents new file mode 100644 index 0000000..3abecb9 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/5437C517-contents @@ -0,0 +1,38 @@ +#install.packages("RPostgres") +library(RPostgres) +library(DBI) + +#' AIM: We want to be able to call the original data, clean it / remove the irrelevant ones +#' and then save that so we can call just this reduced data set. + +#Connect to Database to get original data +plh_con <- DBI::dbConnect(RPostgres::Postgres(), + dbname = 'early_family_math', + host = 'apps-server.idems.international', + port = 5432, + user = 'early_family_math', + password = 'nPmtPjhi2HuQDz') + +# TODO: explore do a query (filter) +#DBI::dbReadTable(conn = plh_con, name = "app_users") + + +#Connect to Database to write cleaned data +# parent_app_con <- dbConnect(RPostgres::Postgres(), +# dbname = 'parent_app', +# host = 'apps-server.idems.international', +# port = 5432, +# user = 'parent_app', +# password = 'parent_app') +# +# parent_app_tables <- dbListTables(plh_con) + +# x <- system.time(DBI::dbReadTable(conn = plh_con, name = "app_users")) +# +# y <- system.time(DBI::dbReadTable(conn = parent_app_con, name = "plhdata_org_clean")) +# +# x; y + +#dbListTables(parent_app_con) +#plhdata_org <- DBI::dbReadTable(conn = parent_app_con, name = "plhdata_org_clean") +#plhdata_org <- DBI::dbReadTable(conn = parent_app_con, name = "Cleaned PLH data") diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3 b/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3 new file mode 100644 index 0000000..b758515 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3 @@ -0,0 +1,26 @@ +{ + "id": "578901C3", + "path": "~/GitHub/EFMDataScripts/app.R", + "project_path": "app.R", + "type": "r_source", + "hash": "0", + "contents": "", + "dirty": false, + "created": 1712756115410.0, + "source_on_save": false, + "relative_order": 1, + "properties": { + "source_window_id": "", + "Source": "Source", + "cursorPosition": "32,39", + "scrollLine": "24" + }, + "folds": "", + "lastKnownWriteTime": 1712821990, + "encoding": "UTF-8", + "collab_server": "", + "source_window": "", + "last_content_update": 1712821990792, + "read_only": false, + "read_only_alternatives": [] +} \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3-contents new file mode 100644 index 0000000..9cc219c --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/578901C3-contents @@ -0,0 +1,40 @@ +# Template file to run PLHR changes. +library(rio) +library(plhR) +library(shiny) +#library(shinythemes) +library(shinyjs) +library(plotly) +library(shinydashboard) +library(jsonlite) +library(rjson) +library(here) +library(ggplot2) +library(tibble) +library(stringr) +library(forcats) +library(lubridate) +library(purrr) +library(tidyr) +library(dplyr) +library(gt) +library(readxl) +library(postgresr) +library(ggthemes) +library(shinyauthr) + +# R files where we call and tidy the data +source("Personal Setup.R") +source("Functions.R") +source("EFM_loading_data.R") +source("Credentials_data.R") + +# Excel file with the specifications in it +data_l <- import_list("EFM_shiny.xlsx") +#data_l$contents <- data_l$contents[1:3,] + +# Run the shiny dashboard +PLH_shiny(title = "EFM Research", + data_list = data_l, + data_frame = plhdata_org, + status = "primary") diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/7E27F9C7-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/7E27F9C7-contents new file mode 100644 index 0000000..cfcc622 --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/7E27F9C7-contents @@ -0,0 +1,130 @@ +#devtools::install_github("IDEMSInternational/postgresr") +#devtools::install_github("IDEMSInternational/plhR") + +data_l <- import_list("EFM_shiny.xlsx") + +# Download data ---------------------------------------------------------------- +# download EFM app data from Metabase as an RDS file? + +plhdata_org <- postgresr::get_user_data(site = plh_con, filter = FALSE) + +# plhdata_org <- get_user_data(filter_variable = "app_deployment_name", +# filter_variable_value = "early_family_math", +# site = plh_con, merge_check = FALSE, filter = TRUE) +#names(plhdata_org) <- gsub(x = names(plhdata_org), pattern = "\\-", replacement = ".") +#View(plhdata_org) + +mydate <- "2023-12-15" +plhdata_org <- plhdata_org %>% filter(as.Date(createdAt) > as.Date(mydate)) + +# filter to web users? +plhdata_org <- plhdata_org %>% dplyr::filter(nchar(app_user_id) == 16) + +# filter to individuals from Kenya +token_matomo <- read.table("token_matomo", quote="\"", comment.char="") +efm_kenya <- calling_matomo_data(type = "EFM_KE") +kenyan_ids <- efm_kenya$UUID +plhdata_org <- plhdata_org %>% dplyr::filter(app_user_id %in% kenyan_ids) + +# COUNTING the number of clicks -------------------------------------------------------------------- +### Creating counts +#x <- c("2023-11-24T09:28:59 ; 2023-11-24T09:30:22", NA, "2023-11-27T14:45:52") + +# Apply the function to each element of the vector + +# METHOD 1: sapply +# plhdata_org1 <- plhdata_org %>% +# mutate(count_activities_button_click_history = +# sapply(`rp-contact-field.activities_button_click_history`, count_dates)) +# plhdata_org1 %>% dplyr::select(count_activities_button_click_history, `rp-contact-field.activities_button_click_history`) + +# METHOD 2: purrr +# plhdata_org2 <- plhdata_org %>% +# mutate(count_activities_button_click_history_purrr = +# purrr::map_dbl(.x = `rp-contact-field.activities_button_click_history`, +# .f = ~ count_dates(.x))) +# +# plhdata_org2 %>% dplyr::select(count_activities_button_click_history, count_activities_button_click_history_purrr, rp.contact.field.activities_button_click_history) %>% View() +# + +# METHOD 3: multiple columns +plhdata_org <- plhdata_org %>% + mutate(across(ends_with("_click_history"), # put in here a set of variables. + .names = "{.col}_count", # rename the new variables + ~ sapply(.x, count_dates))) # apply count_dates to them. +#plhdata_org_3 %>% View() + + + +######################################### Hello - fixes and comments ####################################### + +# we got an error in shiny: +# Caused by error in `.data[["rp-contact-field.efm_sb_Cat_And_Dog_And_The_Ball_book_click_history"]]`: +# ! Column `rp-contact-field.efm_sb_Cat_And_Dog_And_The_Ball_book_click_history` not found in `.data`. + +# lets check if these variables exist + +vars_to_check <- data_l$storybooks$variable +plhdata_org <- add_na_variable(data = plhdata_org, variable = vars_to_check) + +# WARNING: Please please check when you do this - this code creates the variable and fills with NAs if it +# is not in the data set. +# However, it may be that this variable is a typo, and so therefore you need to check the typo and fix it that way. +# Please make sure of this. I've noticed some typos already - e.g. you said +# app_last_launch, not rp-contact-field.app_last_launch. I've fixed this on run_plhr_shiny.R + +#### Fix namings for rp-contact-field.current_book +# We just want to remove "data.efm_storybooks.efm_sb_" from our names +plhdata_org$`rp-contact-field.current_book` <- naming_conventions(plhdata_org$`rp-contact-field.current_book`, + "data.efm_storybooks.efm_sb_") + + +#TODO: remove data column in spreadsheet +plhdata_org$`rp-contact-field._server_sync_latest` <- lubridate::as_date(plhdata_org$`rp-contact-field._server_sync_latest`) +plhdata_org$`app_last_launch` <- plhdata_org$`rp-contact-field.app_last_launch` +plhdata_org$`app_launch_count` <- plhdata_org$`rp-contact-field.app_launch_count` + +#App last sync +plhdata_org <- plhdata_org %>% + mutate(synced_7_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 7, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_7_14_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 14 & + `rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 7, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_14_30_days = ifelse(`rp-contact-field._server_sync_latest` >= as.Date(lubridate::now(tzone = "UTC")) - 30 & + `rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 14, + 1,0)) + +plhdata_org <- plhdata_org %>% + mutate(synced_more_than_30_days = ifelse(`rp-contact-field._server_sync_latest` < as.Date(lubridate::now(tzone = "UTC")) - 30, + 1,0)) + +plhdata_org$app_last_launch <- as.Date(plhdata_org$app_last_launch) + +# # App last launch - line graph +# plhdata_org$app_last_launch <- as.Date(plhdata_org$app_last_launch) +# +# # Creating a data frame of the last lauched dates +# app_last_launch_data <- plhdata_org %>% +# filter(!is.na(app_last_launch)) %>% +# group_by(app_last_launch) %>% +# summarise(frequency = n()) + +# Creating the line graph +# ggplot(app_last_launch_data) + +# geom_line(aes(x = app_last_launch, y = frequency)) + +# geom_point(aes(x = app_last_launch, y = frequency)) + +# labs(x = "Date", y = "Frequency", title = "Frequency of Values by Date") +# + + + + + + + + diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/EC75C9F7-contents b/.Rproj.user/DC486B7A/sources/session-6291cfb0/EC75C9F7-contents new file mode 100644 index 0000000..334bf4b --- /dev/null +++ b/.Rproj.user/DC486B7A/sources/session-6291cfb0/EC75C9F7-contents @@ -0,0 +1,5 @@ +credentials_data <- data.frame( + user = c("admin"), + password = c("Efm2024R*?=."), + stringsAsFactors = FALSE +) \ No newline at end of file diff --git a/.Rproj.user/DC486B7A/sources/session-6291cfb0/lock_file b/.Rproj.user/DC486B7A/sources/session-6291cfb0/lock_file new file mode 100644 index 0000000..e69de29 diff --git a/EFM_loading_data.R b/EFM_loading_data.R index a02a7c8..6fc0432 100644 --- a/EFM_loading_data.R +++ b/EFM_loading_data.R @@ -25,6 +25,8 @@ token_matomo <- read.table("token_matomo", quote="\"", comment.char="") efm_kenya <- calling_matomo_data(type = "EFM_KE") kenyan_ids <- efm_kenya$UUID plhdata_org <- plhdata_org %>% dplyr::filter(app_user_id %in% kenyan_ids) +plhdata_org <- full_join(plhdata_org, efm_kenya, by = c("app_user_id" = "UUID")) + # COUNTING the number of clicks -------------------------------------------------------------------- ### Creating counts @@ -82,7 +84,8 @@ plhdata_org$`rp-contact-field.current_book` <- naming_conventions(plhdata_org$`r #TODO: remove data column in spreadsheet plhdata_org$`rp-contact-field._server_sync_latest` <- lubridate::as_date(plhdata_org$`rp-contact-field._server_sync_latest`) plhdata_org$`app_last_launch` <- plhdata_org$`rp-contact-field.app_last_launch` -plhdata_org$`app_launch_count` <- plhdata_org$`rp-contact-field.app_launch_count` +plhdata_org $ app_last_launch_month <- as.yearmon(plhdata_org$app_last_launch) +plhdata_org$`app_launch_count` <- as.numeric(plhdata_org$`rp-contact-field.app_launch_count`) #App last sync plhdata_org <- plhdata_org %>% diff --git a/EFM_shiny.xlsx b/EFM_shiny.xlsx index e7f0e3adb52dea61bccc18aa6e99eec4d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&)zlhgG9o0 zy2Zt_t4b$#c0AG4);>tJjajf1zcog6DmL(=u3voXJ2!We7g`k+PD-qvEI9v*AbKs{ps0rd2O;{h}mbqEH)$`oc1T%o@ z=%|KMy$)X8`XupB$gJ`_n#4cF3K#{(&E&rcvMjm|yJvJs`|VQfz%k@|=hbgOHl(@PWav=P z^`{G8OaCmO9>=m9zi-egZ`_-KpX)dJB2Xh3qBC#B^{}=)=+cj0X@2*Y2nP}!rMj36 zoSi3E{+{!8oq)L)vKu$P(f3`bdzK6cC%-shGBE_v^8f$n3Sq+kbi?{;A z8X8Z^a#&Fr-xs>Nhhmz8{DFF+=45P z0TTpfLT^Oune|VfZh9QIizc^9Mbi4P&MTbr1&K}4W8Li;5!v?Zr?Fl2M6O`3ZeI;< z7p_#iUd_3XMLKE_@$&)VlEY-9ntIw6KbsMa<3Vx4WuZHtT=kG}i}s_DFg3}W4Oxjb zF%DSpqb)amw{yHHv(3h$LK)8jkBXeALa#n7ia$hbg%_;-9B;?85NsD>^ZPGjM;=Jp z5qHj?7sfyXY5%zzR&31tnYr@wbQ*b|OBkAUHll-YryxR=Vx zbObqEyBrL+rOYAp-vhu20Q_ZxzX}Kt`Q0mVf+{E=9(PyeD)22XOGOz-!40ci6#CmC zKmdU0ccz8>MgLv@D7^4f7KfA-_#>jUPip)U-SM03xyx? diff --git a/app.R b/app.R index 9cc219c..d0f2816 100644 --- a/app.R +++ b/app.R @@ -22,6 +22,7 @@ library(readxl) library(postgresr) library(ggthemes) library(shinyauthr) +library(zoo) # R files where we call and tidy the data source("Personal Setup.R")