From 2ff3d277d06cf232bb84882d0342d859f475621b Mon Sep 17 00:00:00 2001 From: AsmaBahamyirou Date: Tue, 13 Aug 2024 15:52:21 -0400 Subject: [PATCH] Update Accessing Public Data.r (#57) --- docs/examples/Accessing Public Data.r | 66 +++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/docs/examples/Accessing Public Data.r b/docs/examples/Accessing Public Data.r index d9f42d8..5a080b4 100644 --- a/docs/examples/Accessing Public Data.r +++ b/docs/examples/Accessing Public Data.r @@ -24,17 +24,63 @@ execute_query <- function(endpoint, query) { # Query for retrieving data from the 'Infobase' table - this table is public query_infobase <- Query$new() query_infobase$query('Infobase', '{ - Infobase { - Date - Location - region - measureid - fractionid - viral_load - seven_day_rolling_avg - pruid - } + Infobase { + Date + Location + region + measureid + fractionid + viral_load + seven_day_rolling_avg + pruid + } + + + +}') + +query_WastewaterAtEpiYearWeek <- Query$new() +query_WastewaterAtEpiYearWeek$query('WastewaterAtEpiYearWeek', '{ + WastewaterAtEpiYearWeek { + Location + SiteName + City + Province + Country + EpiYear + EpiWeek + Week_start + measure + w_avg + min + max + Population_Coverage + pruid + } + + +}') + +query_InfobaseTrend <- Query$new() +query_InfobaseTrend$query('InfobaseTrend', '{ + InfobaseTrend { + Location + measure + latestTrends + pruid + t_low + t_high + LatestLevel + Grouping + City + Province + Country + } + + }') # Call execute_query function to execute GraphQL queries and parse JSON results into data frames Infobase_df <- execute_query(endpoint, query_infobase$queries$Infobase)[["Infobase"]] +InfobaseTrend_df <- execute_query(endpoint, query_InfobaseTrend$queries$InfobaseTrend)[["InfobaseTrend"]] +WastewaterAtEpiYearWeek_df <- execute_query(endpoint, query_WastewaterAtEpiYearWeek$queries$WastewaterAtEpiYearWeek)[["WastewaterAtEpiYearWeek"]]