Title: | Generator from American Community Survey Geodatabases |
---|---|
Description: | The American Community Survey (ACS) <https://www.census.gov/programs-surveys/acs> offers geodatabases with geographic information and associated data of interest to researchers in the area. The goal of this package is to generate objects that allow us to access and consult the information available in various formats, such as in 'GeoPackage' format or in multidimensional 'ROLAP' (Relational On-Line Analytical Processing) star format. |
Authors: | Jose Samos [aut, cre] , Universidad de Granada [cph] |
Maintainer: | Jose Samos <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.1 |
Built: | 2024-11-04 06:41:24 UTC |
Source: | CRAN |
acs_5yr
S3 classAn acs_5yr
object is created from a given local dir. This dir will contain
the geodatabase files that we download.
acs_5yr(dir = "")
acs_5yr(dir = "")
dir |
A string. |
An acs_5yr
object.
Other data download functions:
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir = dir)
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir = dir)
Available selected Demographic and Economic Data from the American Community Survey (ACS) 5-year estimates data titles and years.
acs_5yr_md
acs_5yr_md
A vector list.
Topic selected for the area and years indicated: "Alaska Native Regional Corporation", 2021.
anrc_2021_x01
anrc_2021_x01
An acs_5yr_topic
object.
# Defined by: dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() anrc_2021_x01 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex")
# Defined by: dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() anrc_2021_x01 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex")
acs_5yr_geo
objectOnce we have selected the topics that interest us and, possibly also the reports
or subreports, we obtain an acs_5yr_geo
object with which we can represent
or export the geographic layer along with the data of interest more easily.
as_acs_5yr_geo(act) ## S3 method for class 'acs_5yr_topic' as_acs_5yr_geo(act)
as_acs_5yr_geo(act) ## S3 method for class 'acs_5yr_topic' as_acs_5yr_geo(act)
act |
An |
An acs_5yr_geo
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_flat_table()
,
as_geomultistar()
,
as_star_database()
,
get_metadata()
,
set_metadata()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo()
Gets an ACS census topic object (report group) for the given years of the Demographic and Economic Areas that are downloaded and unzipped, available to be queried.
as_acs_5yr_topic(ac, area, years, topic) ## S3 method for class 'acs_5yr' as_acs_5yr_topic(ac, area, years = NULL, topic = NULL)
as_acs_5yr_topic(ac, area, years, topic) ## S3 method for class 'acs_5yr' as_acs_5yr_topic(ac, area, years = NULL, topic = NULL)
ac |
An |
area |
A string, area name. |
years |
A vector, year number. |
topic |
A vector, topic name. |
If no year is indicated, all available years are taken. If no topic is given, the first one that appears in the files is taken.
An acs_5yr_topic
object.
Other data selection functions:
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() anrc_2021_x01 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex") anrc_2021_2022_x01_x07 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", topic = c("X01 Age And Sex", "X07 Migration"))
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() anrc_2021_x01 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex") anrc_2021_2022_x01_x07 <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", topic = c("X01 Age And Sex", "X07 Migration"))
rolap::flat_table
objectObtain an rolap::flat_table
object to be able to modify the data or integrate
it with other data.
as_flat_table(act, attributes) ## S3 method for class 'acs_5yr_topic' as_flat_table(act, attributes = NULL)
as_flat_table(act, attributes) ## S3 method for class 'acs_5yr_topic' as_flat_table(act, attributes = NULL)
act |
An |
attributes |
A string vector. |
We can indicate the attributes of the geographic layer to include in the export. Otherwise, the default attributes are included (not area, perimeter or location attributes).
A flat_table
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_acs_5yr_geo()
,
as_geomultistar()
,
as_star_database()
,
get_metadata()
,
set_metadata()
ft <- anrc_2021_x01 |> as_flat_table()
ft <- anrc_2021_x01 |> as_flat_table()
geomultistar::geomultistar
objectObtain an geomultistar::geomultistar
object to be able to enrich multidimensional
queries with geographic data.
as_geomultistar(act, attributes) ## S3 method for class 'acs_5yr_topic' as_geomultistar(act, attributes = NULL)
as_geomultistar(act, attributes) ## S3 method for class 'acs_5yr_topic' as_geomultistar(act, attributes = NULL)
act |
An |
attributes |
A string vector. |
We can indicate the attributes of the geographic layer to include in the export. Otherwise, the default attributes are included (not area, perimeter or location attributes).
A geomultistar
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_acs_5yr_geo()
,
as_flat_table()
,
as_star_database()
,
get_metadata()
,
set_metadata()
gms <- anrc_2021_x01 |> as_geomultistar()
gms <- anrc_2021_x01 |> as_geomultistar()
GeoPackage
Save the data layer (geographic information layer), the metadata layer and the
data source description layer in a file in GeoPackage
format to be able to
work with other tools.
as_GeoPackage(geo, dir, name) ## S3 method for class 'acs_5yr_geo' as_GeoPackage(geo, dir = NULL, name = NULL)
as_GeoPackage(geo, dir, name) ## S3 method for class 'acs_5yr_geo' as_GeoPackage(geo, dir = NULL, name = NULL)
geo |
An |
dir |
A string. |
name |
A string, file name. |
The GeoPackage
format only allows defining a maximum of 1998 columns. If the
number of variables and columns in the geographic layer exceeds this number,
it cannot be saved in this format.
A string, file name.
Other data exploitation and export functions:
as_acs_5yr_geo()
,
as_flat_table()
,
as_geomultistar()
,
as_star_database()
,
get_metadata()
,
set_metadata()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() dir <- tempdir() file <- geo |> as_GeoPackage(dir)
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() dir <- tempdir() file <- geo |> as_GeoPackage(dir)
rolap::star_database
objectObtain an rolap::star_database
object to be able to export it to a RDBMS and
make queries with other tools.
as_star_database(act, attributes) ## S3 method for class 'acs_5yr_topic' as_star_database(act, attributes = NULL)
as_star_database(act, attributes) ## S3 method for class 'acs_5yr_topic' as_star_database(act, attributes = NULL)
act |
An |
attributes |
A string vector. |
We can indicate the attributes of the geographic layer to include in the export. Otherwise, the default attributes are included (not area, perimeter or location attributes).
A star_database
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_acs_5yr_geo()
,
as_flat_table()
,
as_geomultistar()
,
get_metadata()
,
set_metadata()
st <- anrc_2021_x01 |> as_star_database()
st <- anrc_2021_x01 |> as_star_database()
Download the files that have been selected and have not been downloaded yet, unzip them (if desired) and, if everything went well and is indicated in the parameter, delete the downloaded files.
download_selected_files(ac, subdir = NULL, unzip = TRUE, delete_zip = FALSE)
download_selected_files(ac, subdir = NULL, unzip = TRUE, delete_zip = FALSE)
ac |
An |
subdir |
NULL/'year'/'area', output subdir. |
unzip |
A boolean, unzip files. |
delete_zip |
A boolean, delete zip files if correctly unzipped. |
In the subdir
parameter, the values NULL, 'year' or 'area' can be indicated.
With NULL it does not create any subdirs, with 'year' it creates them by years
of downloaded files and with 'area' it creates them by areas.
A vector, files correctly obtained.
Other data download functions:
acs_5yr()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) ac <- ac |> select_area_files("Alaska Native Regional Corporation", 2020:2021) files <- ac |> download_selected_files(unzip = FALSE)
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) ac <- ac |> select_area_files("Alaska Native Regional Corporation", 2020:2021) files <- ac |> download_selected_files(unzip = FALSE)
Get area url file names for the given years. If no year is indicated, all available ones are obtained.
get_area_file_names(ac, area, years) ## S3 method for class 'acs_5yr' get_area_file_names(ac, area, years = NULL)
get_area_file_names(ac, area, years) ## S3 method for class 'acs_5yr' get_area_file_names(ac, area, years = NULL)
ac |
An |
area |
A string, area name. |
years |
A vector, year number. |
A vector, file urls.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) url <- ac |> get_area_file_names("State", 2019:2021) url <- ac |> get_area_file_names("State")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) url <- ac |> get_area_file_names("State", 2019:2021) url <- ac |> get_area_file_names("State")
Gets the names of the Demographic and Economic Area Groups where data is available.
get_area_groups(ac) ## S3 method for class 'acs_5yr' get_area_groups(ac)
get_area_groups(ac) ## S3 method for class 'acs_5yr' get_area_groups(ac)
ac |
An |
A vector, area group names.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_area_groups()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_area_groups()
Get the years for which data has been found to be available for an area.
get_area_years(ac, area) ## S3 method for class 'acs_5yr' get_area_years(ac, area)
get_area_years(ac, area) ## S3 method for class 'acs_5yr' get_area_years(ac, area)
ac |
An |
area |
A string, area name. |
A vector, area years.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) years <- ac |> get_area_years(area = "State")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) years <- ac |> get_area_years(area = "State")
Gets the names of the Demographic and Economic Areas of a group or set of groups.
get_areas(ac, group) ## S3 method for class 'acs_5yr' get_areas(ac, group = NULL)
get_areas(ac, group) ## S3 method for class 'acs_5yr' get_areas(ac, group = NULL)
ac |
An |
group |
A string, area group name. |
If no group is indicated, all available areas are obtained.
A vector, area names.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) areas <- ac |> get_areas(group = "Statistical Areas")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) areas <- ac |> get_areas(group = "Statistical Areas")
Gets the topics (report groups) for the given years of the Demographic and Economic Areas that are downloaded and unzipped, available to be queried.
get_available_area_topics(ac, area, years) ## S3 method for class 'acs_5yr' get_available_area_topics(ac, area, years = NULL)
get_available_area_topics(ac, area, years) ## S3 method for class 'acs_5yr' get_available_area_topics(ac, area, years = NULL)
ac |
An |
area |
A string, area name. |
years |
A vector, year number. |
A vector, available report groups.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() topics <- ac |> get_available_area_topics("Alaska Native Regional Corporation", 2021) topics <- ac |> get_available_area_topics("Alaska Native Regional Corporation")
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() topics <- ac |> get_available_area_topics("Alaska Native Regional Corporation", 2021) topics <- ac |> get_available_area_topics("Alaska Native Regional Corporation")
Gets the years of the Demographic and Economic Areas that are downloaded and unzipped, available to be queried.
get_available_area_years(ac, area) ## S3 method for class 'acs_5yr' get_available_area_years(ac, area)
get_available_area_years(ac, area) ## S3 method for class 'acs_5yr' get_available_area_years(ac, area)
ac |
An |
area |
A string, area name. |
A vector, area years.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() years <- ac |> get_available_area_years(area = "Alaska Native Regional Corporation")
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() years <- ac |> get_available_area_years(area = "Alaska Native Regional Corporation")
Gets the names of the Demographic and Economic Areas that are downloaded and unzipped, available to be queried.
get_available_areas(ac) ## S3 method for class 'acs_5yr' get_available_areas(ac)
get_available_areas(ac) ## S3 method for class 'acs_5yr' get_available_areas(ac)
ac |
An |
A vector, area names.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() areas <- ac |> get_available_areas()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() areas <- ac |> get_available_areas()
Obtain the code that appears in the name of the file associated with the area.
get_code_from_area_name(ac, area) ## S3 method for class 'acs_5yr' get_code_from_area_name(ac, area)
get_code_from_area_name(ac, area) ## S3 method for class 'acs_5yr' get_code_from_area_name(ac, area)
ac |
An |
area |
A string, area name. |
A vector, area code.
Other information functions:
get_name_from_area_code()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) code <- ac |> get_code_from_area_name(area = "State")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) code <- ac |> get_code_from_area_name(area = "State")
Get the names of the geographic layer attributes (except for the geometry field).
get_geo_attribute_names(act) ## S3 method for class 'acs_5yr_topic' get_geo_attribute_names(act)
get_geo_attribute_names(act) ## S3 method for class 'acs_5yr_topic' get_geo_attribute_names(act)
act |
An |
A vector, geographical attribute names.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
names <- anrc_2021_x01 |> get_geo_attribute_names()
names <- anrc_2021_x01 |> get_geo_attribute_names()
Get the geographic layer.
## S3 method for class 'acs_5yr_geo' get_geo_layer(glc) get_geo_layer(glc) ## S3 method for class 'acs_5yr_topic' get_geo_layer(glc)
## S3 method for class 'acs_5yr_geo' get_geo_layer(glc) get_geo_layer(glc) ## S3 method for class 'acs_5yr_topic' get_geo_layer(glc)
glc |
An |
A sf
object.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
layer <- anrc_2021_x01 |> get_geo_layer()
layer <- anrc_2021_x01 |> get_geo_layer()
The metadata layer includes the names and description through various fields of the variables contained in the reports.
get_metadata(geo) ## S3 method for class 'acs_5yr_geo' get_metadata(geo)
get_metadata(geo) ## S3 method for class 'acs_5yr_geo' get_metadata(geo)
geo |
An |
The way to select the variables we want to work with is to filter this layer
and subsequently set it as the object's metadata layer using the set_metadata()
function.
A tibble
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_acs_5yr_geo()
,
as_flat_table()
,
as_geomultistar()
,
as_star_database()
,
set_metadata()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() metadata <- geo |> get_metadata()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() metadata <- geo |> get_metadata()
Get the name of the area from the code that appears in the name of the area files.
get_name_from_area_code(ac, area) ## S3 method for class 'acs_5yr' get_name_from_area_code(ac, area)
get_name_from_area_code(ac, area) ## S3 method for class 'acs_5yr' get_name_from_area_code(ac, area)
ac |
An |
area |
A string, area name. |
A vector, area code.
Other information functions:
get_code_from_area_name()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) name <- ac |> get_name_from_area_code(area = "METDIV")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) name <- ac |> get_name_from_area_code(area = "METDIV")
The area that we have downloaded has a set of defined topics, we have selected one of them, this function shows us the rest of the available topics in the area.
get_names_of_other_topics(act) ## S3 method for class 'acs_5yr_topic' get_names_of_other_topics(act)
get_names_of_other_topics(act) ## S3 method for class 'acs_5yr_topic' get_names_of_other_topics(act)
act |
An |
A vector, available topics.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
topics <- anrc_2021_x01 |> get_names_of_other_topics()
topics <- anrc_2021_x01 |> get_names_of_other_topics()
Each topic includes several reports. Once a topic has been selected, using this function we obtain the name of the available reports. The report code is included with the name. Each report can contain multiple subreports.
get_report_names(act) ## S3 method for class 'acs_5yr_topic' get_report_names(act)
get_report_names(act) ## S3 method for class 'acs_5yr_topic' get_report_names(act)
act |
An |
A vector, report names.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
reports <- anrc_2021_x01 |> get_report_names()
reports <- anrc_2021_x01 |> get_report_names()
Gets the names of the files selected to be downloaded.
get_selected_file_names(ac) ## S3 method for class 'acs_5yr' get_selected_file_names(ac)
get_selected_file_names(ac) ## S3 method for class 'acs_5yr' get_selected_file_names(ac)
ac |
An |
A vector, file names.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_too_heavy_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_selected_file_names()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_selected_file_names()
Each topic includes several reports and subreports. Once a topic has been selected, using this function we obtain the name of the available subreports of a report. If no report is indicated, all subreports of the topic are obtained.
get_subreport_names(act, report) ## S3 method for class 'acs_5yr_topic' get_subreport_names(act, report = NULL)
get_subreport_names(act, report) ## S3 method for class 'acs_5yr_topic' get_subreport_names(act, report = NULL)
act |
An |
report |
A string, report name. |
A vector, subreport names.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
,
select_topic()
reports <- anrc_2021_x01 |> get_subreport_names(report = "B01002-Median Age By Sex")
reports <- anrc_2021_x01 |> get_subreport_names(report = "B01002-Median Age By Sex")
Gets the names of the files that are too heavy to be download with the available function. We have downloaded them directly with the web browser.
get_too_heavy_file_names(ac) ## S3 method for class 'acs_5yr' get_too_heavy_file_names(ac)
get_too_heavy_file_names(ac) ## S3 method for class 'acs_5yr' get_too_heavy_file_names(ac)
ac |
An |
A vector, too heavy file names.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
select_area_files()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_too_heavy_file_names()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) groups <- ac |> get_too_heavy_file_names()
Get the selected topic by which this object has been defined.
get_topic_name(act) ## S3 method for class 'acs_5yr_topic' get_topic_name(act)
get_topic_name(act) ## S3 method for class 'acs_5yr_topic' get_topic_name(act)
act |
An |
A topic is made up of a set of reports.
A vector, topic name.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
select_report()
,
select_subreport()
,
select_topic()
topic <- anrc_2021_x01 |> get_topic_name()
topic <- anrc_2021_x01 |> get_topic_name()
Select area files for the given years. If no year is indicated, all available ones are selected.
select_area_files(ac, area, years) ## S3 method for class 'acs_5yr' select_area_files(ac, area, years = NULL)
select_area_files(ac, area, years) ## S3 method for class 'acs_5yr' select_area_files(ac, area, years = NULL)
ac |
An |
area |
A string, area name. |
years |
A vector, year number. |
An acs_5yr
object.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
unzip_files()
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) ac <- ac |> select_area_files("State", 2019:2021) ac <- ac |> select_area_files("State")
dir <- system.file("extdata/acs_5yr", package = "geogenr") ac <- acs_5yr(dir) ac <- ac |> select_area_files("State", 2019:2021) ac <- ac |> select_area_files("State")
Select the reports whose names are indicated. We reduce the available reports and variables to those of the selected reports.
select_report(act, report) ## S3 method for class 'acs_5yr_topic' select_report(act, report = NULL)
select_report(act, report) ## S3 method for class 'acs_5yr_topic' select_report(act, report = NULL)
act |
An |
report |
A string vector, report names. |
An acs_5yr_topic
object.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_subreport()
,
select_topic()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex")
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex")
Select the subreports whose names are indicated. We reduce the available subreports and variables to those of the selected subreports.
select_subreport(act, subreport) ## S3 method for class 'acs_5yr_topic' select_subreport(act, subreport = NULL)
select_subreport(act, subreport) ## S3 method for class 'acs_5yr_topic' select_subreport(act, subreport = NULL)
act |
An |
subreport |
A string vector, subreport names. |
A vector, topic name.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_topic()
act2 <- anrc_2021_x01 |> select_subreport( c( "B01002-B-Median Age By Sex (Black Or African American Alone)", "B01002-C-Median Age By Sex (American Indian And Alaska Native Alone)" ) )
act2 <- anrc_2021_x01 |> select_subreport( c( "B01002-B-Median Age By Sex (Black Or African American Alone)", "B01002-C-Median Age By Sex (American Indian And Alaska Native Alone)" ) )
Select a topic. If no topic is given, the first one that appears in the area is taken.
select_topic(act, topic) ## S3 method for class 'acs_5yr_topic' select_topic(act, topic = NULL)
select_topic(act, topic) ## S3 method for class 'acs_5yr_topic' select_topic(act, topic = NULL)
act |
An |
topic |
A string, topic name. |
An acs_5yr_topic
object.
Other data selection functions:
as_acs_5yr_topic()
,
get_available_area_topics()
,
get_available_area_years()
,
get_available_areas()
,
get_geo_attribute_names()
,
get_geo_layer.acs_5yr_geo()
,
get_names_of_other_topics()
,
get_report_names()
,
get_subreport_names()
,
get_topic_name()
,
select_report()
,
select_subreport()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() act <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex") act <- act |> select_topic(topic = "X03 Hispanic Or Latino Origin")
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files() act <- ac |> as_acs_5yr_topic("Alaska Native Regional Corporation", 2021, "X01 Age And Sex") act <- act |> select_topic(topic = "X03 Hispanic Or Latino Origin")
The metadata layer includes the names and description through various fields of the variables contained in the reports.
set_metadata(geo, metadata) ## S3 method for class 'acs_5yr_geo' set_metadata(geo, metadata)
set_metadata(geo, metadata) ## S3 method for class 'acs_5yr_geo' set_metadata(geo, metadata)
geo |
An |
metadata |
A |
When we set the metadata layer, after filtering it, the data layer is also filtered keeping only the variables from the metadata layer.
A sf
object.
Other data exploitation and export functions:
as_GeoPackage()
,
as_acs_5yr_geo()
,
as_flat_table()
,
as_geomultistar()
,
as_star_database()
,
get_metadata()
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() metadata <- geo |> get_metadata() metadata <- dplyr::filter(metadata, item2 == "Female") geo2 <- geo |> set_metadata(metadata)
act <- anrc_2021_x01 |> select_report(report = "B01002-Median Age By Sex") geo <- act |> as_acs_5yr_geo() metadata <- geo |> get_metadata() metadata <- dplyr::filter(metadata, item2 == "Female") geo2 <- geo |> set_metadata(metadata)
Unzip files that are not already unzipped in the object and, if everything went well and is indicated in the parameter, delete the unzipped files.
unzip_files(ac, subdir = NULL, delete_zip = FALSE)
unzip_files(ac, subdir = NULL, delete_zip = FALSE)
ac |
An |
subdir |
NULL/'year'/'area', output subdir. |
delete_zip |
A boolean, delete zip files if correctly unzipped. |
In the subdir
parameter, the values NULL, 'year' or 'area' can be indicated.
With NULL it does not create any subdirs, with 'year' it creates them by years
of files and with 'area' it creates them by areas.
A vector of strings, name of the processed files.
Other data download functions:
acs_5yr()
,
download_selected_files()
,
get_area_file_names()
,
get_area_groups()
,
get_area_years()
,
get_areas()
,
get_selected_file_names()
,
get_too_heavy_file_names()
,
select_area_files()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files()
dir <- tempdir() source_dir <- system.file("extdata/acs_5yr", package = "geogenr") files <- list.files(source_dir, "*.zip", full.names = TRUE) file.copy(from = files, to = dir, overwrite = TRUE) ac <- acs_5yr(dir) files <- ac |> unzip_files()