Get the html text or the path to the html file with a multisite summary or community report
Usage
ejam2report(
ejamitout = testoutput_ejamit_10pts_1miles,
sitenumber = NULL,
logo_path = NULL,
logo_html = NULL,
report_title = NULL,
analysis_title = NULL,
addlatlon = TRUE,
site_method = NULL,
shp = NULL,
show_ratios_in_report = TRUE,
extratable_show_ratios_in_report = TRUE,
extratable_title = "",
extratable_title_top_row = "ADDITIONAL INFORMATION",
extratable_list_of_sections = list(`Breakdown by Population Group` = names_d_subgroups,
`Language Spoken at Home` = names_d_language,
`Language in Limited English Speaking Households` = names_d_languageli,
`Breakdown by Sex` = c("pctmale", "pctfemale"), Health = names_health, Age =
c("pctunder5", "pctunder18", "pctover64"), Community =
names_community[!(names_community %in% c("pctmale", "pctfemale",
"pctownedunits_dupe"))], Poverty = names_d_extra, Climate = names_climate,
`Counts of Features and Overlap with Area Types` = c(names_featuresinarea,
names_flag), `Critical Services` = c("yesno_houseburden", "yesno_fooddesert",
"yesno_transdis", "pctnobroadband", "pctnohealthinsurance"), `Facility Counts` =
names_sitesinarea, `Analyzed Sites` = c("distance_min_avgperson", "distance_min",
"sitecount_unique", "sitecount_avg", "sitecount_max"), `Other Totals` =
names_d_other_count),
extratable_hide_missing_rows_for = as.vector(unlist(extratable_list_of_sections)),
footer_version_number = NULL,
footer_date = NULL,
footer_text = NULL,
footer_html = NULL,
fileextension = c("html", "pdf")[1],
filename = NULL,
return_html = FALSE,
launch_browser = TRUE,
shape = NULL,
shapefile = NULL,
sitenumber_label = NULL
)Arguments
- ejamitout
output as from
ejamit(), list with a table in data.table format calledresults_bysiteif sitenumber parameter is used, or a table in data.table format calledresults_overallotherwise- sitenumber
If a valid number is provided, the report is a "1-site" report, about
ejamitout$results_bysite[sitenumber, ]. If no valid number is provided (e.g., param is omitted, 0, NULL, "", etc.) then the report is a "Multisite" report, aboutejamitout$results_overall. But note that it is treated / titled like a 1-site report if only one site was analyzed (or only one had valid results).- logo_path
optional relative path to a logo for the upper right of the overall header. Ignored if logo_html is specified and not NULL, but otherwise uses default or param set in
ejamapp()- logo_html
optional HTML for img of logo for the upper right of the overall header. If specified, it overrides logo_path. If omitted, gets created based on logo_path.
- report_title
optional generic name of this type of report, to be shown at top, like "EJSCREEN Multisite Report" or "EJSCREEN Community Report". Default is global_or_param("report_title") or global_or_param("report_title_multisite") depending on number of sites analyzed and the sitenumber parameter.
- analysis_title
optional title of analysis, default is global_or_param("default_standard_analysis_title")
- addlatlon
optional, whether to include lat,lon coordinates in header (for "latlon" sitetype)
- site_method
optional word or phrase about the sites or how they were selected.
The
site_methodparameter can be used as-is bycreate_filename()to be part of the saved file name. It can also be used by the shiny app to add informational text in the header of a report, viaejam2report()and related helper functions likereport_residents_within_xyz()or viaejam2excel()and related helper functions.The
site_methodparameter provides more detailed info about how sites were specified in the web app, beyond whatsitetypeprovides (e.g., fromejamit()$sitetypeorejamitout$sitetype):sitetype can be "latlon", "fips", or "shp"
site_method can be one of these: "latlon", "SHP", "FIPS", "FIPS_PLACE", "FRS", "NAICS", "SIC", "EPA_PROGRAM", "MACT"
The shiny app server provides
site_methodfrom the reactive called submitted_upload_method() which is much like the one called current_upload_method().- shp
provide the sf spatial data.frame of polygons that were analyzed so you can map them since they are not in ejamitout
- show_ratios_in_report
logical, whether to add columns with ratios to US and State overall values, in main table of envt/demog. info.
- extratable_show_ratios_in_report
logical, whether to add columns with ratios to US and State overall values, in extra table
- extratable_title
Text of overall title ABOVE the extra table
- extratable_title_top_row
Text INSIDE top left cell of extra table
- extratable_list_of_sections
This defines what extra indicators are shown. It is a named list of vectors, where each name is text phrase that is title of a section of the table, and each vector is the vector of colnames of output_df that are indicators to show in that section, in extra table of demog. subgroups, etc.
- extratable_hide_missing_rows_for
only for the indicators named in this vector, leave out rows in table where raw value is NA, as with many of names_d_language, in extra table of demog. subgroups, etc.
to customize the report footer - see
generate_report_footer()Should provide footer_date to ensure user's timezone is used to determine today's date.- fileextension
html or .html or pdf or .pdf (case-insensitive) - use "pdf" to create a PDF version of the report. PDF generation uses
pagedown::chrome_print()which requires thepagedownpackage and a Chrome/Chromium browser to be available on the system. The PDF preserves the full HTML/CSS styling and supports smart page breaks. If PDF-related dependencies are unavailable, PDF generation stops with a clear error. PDF output is required when this option is selected; it is not optional.- filename
optional path and/or name for report file. How it is interpreted: a bare name like "myreport.html" is saved in tempdir(); a "./"-prefixed or multi-folder path like "./myreport.html" or "out/myreport.html" is saved relative to the working directory (the folder is created if necessary, with a warning and fallback to tempdir() if it cannot be created); an existing folder like "~/Desktop" gets an auto-generated report name inside it; a missing or invalid extension is fixed based on the fileextension parameter, and a valid extension in filename (.html or .pdf) overrides the fileextension parameter (with a warning if the two conflict).
- return_html
set TRUE to have function return HTML object instead of URL of local file
- launch_browser
set TRUE to have it launch browser and show report.
- shape
alias (synonym) for shp
- shapefile
alias (synonym) for shp
- sitenumber_label
optional, display-only override (a number or short text) of the site identifier shown in the 1-site report header and in the report map's marker popup, in place of the
sitenumberrow index.sitenumberstill selects which row ofejamitout$results_bysiteto report on; this only changes the label displayed. Useful when one site from a larger analysis has been re-analyzed alone – e.g., the EJAM API per-site report links made byurl_ejamapi()re-analyze a single site that was row N of the original multisite results, so its row index in the regenerated results (1) is not the site number the user expects to see. A number N is shown as "Site N"; text is shown as-is. Ignored for a multisite report.
Value
URL of temp file or object depending on return_html, and has side effect of launching browser to view it depending on return_html
Details
The report also includes rows showing what percent of the analyzed residents
have each type of feature (school, hospital, place of worship) or area type
(Tribal, nonattainment, impaired waters, CEJST/IRA disadvantaged, etc.)
in (or overlapping) their blockgroup, with ratios to the US and State averages
(see ejam2areafeatures()). For a multisite report those come from
ejamitout$results_summarized$flagged_areas; for a 1-site report they are
calculated for just that site. The rows are omitted if that information
is unavailable (e.g., for outputs saved by older EJAM versions).
Examples
#out <- ejamit(testpoints_10, radius = 3, include_ejindexes = TRUE)
out <- testoutput_ejamit_10pts_1miles
ejam2table_tall(out$results_overall)
if (interactive()) {
ejam2report(out)
x <- ejam2report(out, sitenumber = 1, launch_browser = TRUE)
table_gt_from_ejamit_overall(out$results_overall)
table_gt_from_ejamit_1site(out$results_bysite[1, ])
}