World_R6 | R Documentation |
An instance or object of class world is expected to contain (house) objects from class Country_R6 The methods in this class should merge the data from all added objects and summarise/present them.
An [R6::R6Class] object.
country_name
the name of the country being added. This name should be the one used in creating the Country_R6 object.
country_data
a list housing (to house) clones (copies) of the instance (object) of class Country_R6 being added.
world_data
a tibble containing data from all added countries
world_map
an object of class leaflet (A leaflet map).
world_stats
a tibble containing the counts of health facilities (by type)
add_country()
Add country object (of class Country_R6) to this object
World_R6$add_country(country_name, country_object)
country_name
The name of the country to which the country_object will be associated
country_object
An object, instance of class Country_R6 that contain the data from the APIs for the added country.
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 in the global environment: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() Kenya <- Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key()) # Query the healthsities API: Kenya$ query_health_facilities() # Add a clone of the Country_R6 object \code{Kenya} to the World_R6: object \code{World} World$add_country( country_name = "Kenya", country_object = Kenya) # Country_R6 object do not need to be created in the global env. # Below we create an object of class Country_R6 while adding it to # World_R6 object: World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) }
update_world_data()
Update World data on health sites. This method is usually helpful after a Country_R6 object has queried its health facilities
World_R6$update_world_data(country_name)
country_name
The name of the country for which the method will update the world's data.
Nothing back to the user, but updates world_data, world_map and world_stats.
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Update world data: World$update_world_data(country_name = "Kenya") }
get_country_data()
Get data from a specific country in the World_R6 class
World_R6$get_country_data(country_name)
country_name
The name of the country for which the method will retrieve the data.
A tibble with the specified country health sites data
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request some of Kenya's data back: World$get_country_data(country_name = "Kenya") }
get_country_map()
Get the map showing health facilities in a specific country.
World_R6$get_country_map(country_name)
country_name
The name of the country for which the method will retrieve the map
An object of class leaflet (A leaflet map)
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request Kenya's health facilities map: World$get_country_map(country_name = "Kenya") }
get_world_data()
Get the map showing health facilities in a all added country.
World_R6$get_world_data()
An object of class leaflet (A leaflet map)
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request available (of all included countries) health facilities data: World$get_world_data(country_name = "Kenya") }
get_world_stats()
Get the counts/numbers of health facilities by country name and facility type.
World_R6$get_world_stats()
A tibble containing the request stats
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request available (of all included countries) health facilities stats: World$get_world_stats(country_name = "Kenya") }
get_world_map()
Get a map showing health facilities in all added countries
World_R6$get_world_map()
An object of class leaflet (A leaflet map)
\dontrun{ # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request map of available health facilities from all countries added to the World object : World$get_world_map(country_name = "Kenya") }
clone()
The objects of this class are cloneable with this method.
World_R6$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$add_country` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 in the global environment: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() Kenya <- Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key()) # Query the healthsities API: Kenya$ query_health_facilities() # Add a clone of the Country_R6 object \code{Kenya} to the World_R6: object \code{World} World$add_country( country_name = "Kenya", country_object = Kenya) # Country_R6 object do not need to be created in the global env. # Below we create an object of class Country_R6 while adding it to # World_R6 object: World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$update_world_data` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Update world data: World$update_world_data(country_name = "Kenya") ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$get_country_data` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request some of Kenya's data back: World$get_country_data(country_name = "Kenya") ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$get_country_map` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate a copy of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request Kenya's health facilities map: World$get_country_map(country_name = "Kenya") ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$get_world_data` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request available (of all included countries) health facilities data: World$get_world_data(country_name = "Kenya") ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$get_world_stats` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request available (of all included countries) health facilities stats: World$get_world_stats(country_name = "Kenya") ## End(Not run) ## ------------------------------------------------ ## Method `World_R6$get_world_map` ## ------------------------------------------------ ## Not run: # Instantiate a copy of class World_R6: World <- World_R6$new() # Instantiate two objects of class Country_R6 within the World object: # Note: the following example assumes that the user had set their # healthsites API key into their environment using set_hs_API_key() World$add_country( country_name = "Kenya", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) World$add_country( country_name = "Zambia", country_object = Country_R6$new( country_name = "Kenya", hs_API_key = get_hs_API_key())$ query_health_facilities() ) # Request map of available health facilities from all countries added to the World object : World$get_world_map(country_name = "Kenya") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.