Title: | 'WebAIM' 'WAVE' Accessibility Evaluation Tool |
Version: | 0.1.0 |
Description: | An R interface to the 'WebAIM' 'WAVE' accessibility evaluation API https://wave.webaim.org/api/. This package provides tools for analyzing web pages for accessibility issues, generating reports, and comparing accessibility across multiple websites. |
License: | MIT + file LICENSE |
URL: | https://github.com/benjaminlistyg/waetr |
BugReports: | https://github.com/benjaminlistyg/waetr/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Imports: | dplyr, ggplot2, httr, jsonlite, purrr (≥ 0.3.0), tibble, tools |
Suggests: | mockery, testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-03-20 19:02:36 UTC; benjamin.listyg |
Author: | Benjamin Listyg [aut, cre], Brennah V. Ross [aut] |
Maintainer: | Benjamin Listyg <listyg.ben@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-16 13:50:02 UTC |
Calculate Required API Credits
Description
Calculates total API credits needed for analysis
Usage
calculate_required_credits(n_urls, report_type = 1)
Arguments
n_urls |
Integer. Number of URLs to analyze |
report_type |
Integer. WAVE report type (1-4) |
Value
Integer value of required credits
Check WAVE API Credits
Description
Checks remaining WAVE API credits for the provided key
Usage
check_wave_credits(api_key)
Arguments
api_key |
Character string. WAVE API key |
Value
Numeric value of remaining credits
Examples
## Not run:
credits <- check_wave_credits("your_api_key")
print(sprintf("Remaining credits: %d", credits))
## End(Not run)
Compare Website Accessibility
Description
Main function to generate accessibility comparisons across multiple websites
Usage
compare_accessibility(
input,
api_key = NULL,
site_names = NULL,
plot_type = c("category_counts", "issues", "structure"),
report_type = 1,
theme = "light"
)
Arguments
input |
Character vector. URLs to analyze or paths to JSON files |
api_key |
Character string. WAVE API key (required for URL analysis) |
site_names |
Character vector. Optional custom names for sites |
plot_type |
Character string. Type of visualization:
|
report_type |
Integer. WAVE report type (1-4) |
theme |
Character string. Visual theme for plot (default: "light") |
Value
ggplot object containing the requested visualization
Examples
## Not run:
# Compare multiple websites
p <- compare_accessibility(
input = c("https://example.com", "https://example.org"),
api_key = "your_api_key",
plot_type = "category_counts"
)
# Save the plot to a temporary directory
ggsave(file.path(tempdir(), "accessibility_comparison.png"), p)
## End(Not run)
Process and Visualize WAVE Results
Description
Internal function to process WAVE data and create visualizations
Usage
compare_wave_results(
wave_data,
site_names = NULL,
plot_type = c("category_counts", "issues", "structure"),
theme = "light"
)
Arguments
wave_data |
List. WAVE analysis results |
site_names |
Character vector. Names for each site |
plot_type |
Character string. Type of visualization to generate |
theme |
Character string. Visual theme for plot |
Value
ggplot object containing the visualization
Create Comprehensive Accessibility Report
Description
Generates a complete accessibility report with visualizations and summary data
Usage
create_accessibility_report(
input,
api_key = NULL,
output_dir = NULL,
report_type = 1,
include_plots = TRUE,
custom_theme = "light"
)
Arguments
input |
Character vector. URLs to analyze or paths to JSON files |
api_key |
Character string. WAVE API key (required for URL analysis) |
output_dir |
Character string. Directory to save report files |
report_type |
Integer. WAVE report type (1-4) |
include_plots |
Logical. Whether to include plots in the report (default: TRUE) |
custom_theme |
Character string. Visual theme for plots (default: "light") |
Value
List containing plots and summary data frame
Examples
## Not run:
report <- create_accessibility_report(
input = c("https://example.com", "https://example.org"),
api_key = "your_api_key",
output_dir = tempdir()
)
## End(Not run)
Create HTML Report
Description
Internal function to generate HTML report content
Usage
create_html_report(results, input, report_type)
Arguments
results |
List. Analysis results and plots |
input |
Character vector. Input URLs or files |
report_type |
Integer. WAVE report type used |
Value
Character string containing HTML content
Create HTML Table
Description
Internal function to convert data frame to HTML table
Usage
create_html_table(df)
Arguments
df |
Data frame to convert |
Value
Character string containing HTML table
Create Summary Data from WAVE Results
Description
Generates a summary data frame from WAVE accessibility results
Usage
create_summary_data(input, api_key = NULL, report_type = 1)
Arguments
input |
Character vector. URLs to analyze or paths to JSON files |
api_key |
Character string. WAVE API key (required for URL analysis) |
report_type |
Integer. WAVE report type (1-4) |
Value
Data frame containing summary statistics
Fetch WAVE Analysis Data
Description
Retrieves accessibility analysis data either from WAVE API or local JSON files
Usage
fetch_wave_data(
input,
api_key = NULL,
report_type = 1,
is_json = FALSE,
delay = 1
)
Arguments
input |
Character vector. Either URLs to analyze or paths to JSON files |
api_key |
Character string. WAVE API key (required for URL analysis) |
report_type |
Integer. WAVE report type (1-4):
|
is_json |
Logical. Whether input contains JSON file paths (default: FALSE) |
delay |
Numeric. Delay between API calls in seconds (default: 1) |
Value
List of WAVE analysis results
Examples
## Not run:
# Fetch from URLs
results <- fetch_wave_data(
input = c("https://example.com", "https://example.org"),
api_key = "your_api_key"
)
# Load from JSON files
json_results <- fetch_wave_data(
input = c("site1.json", "site2.json"),
is_json = TRUE
)
## End(Not run)
Generate WAVE Report Filename
Description
Creates a standardized filename for WAVE reports
Usage
generate_report_filename(base_name, type, ext = "png")
Arguments
base_name |
Character string. Base name for the file |
type |
Character string. Type of report |
ext |
Character string. File extension |
Value
Character string containing formatted filename
Plot Category Counts Comparison
Description
Creates a bar plot comparing accessibility category counts across sites
Usage
plot_category_counts(wave_data, sites_df, theme = "light")
Arguments
wave_data |
List. WAVE analysis results |
sites_df |
Data frame. Site information |
theme |
Character string. Visual theme for plot |
Value
ggplot object showing category comparisons
Plot Detailed Issue Comparison
Description
Creates a faceted bar plot showing detailed accessibility issues
Usage
plot_issue_details(wave_data, sites_df, theme = "light")
Arguments
wave_data |
List. WAVE analysis results |
sites_df |
Data frame. Site information |
theme |
Character string. Visual theme for plot |
Value
ggplot object showing issue details
Plot Structural Element Comparison
Description
Creates a bar plot comparing structural elements across sites
Usage
plot_structure_comparison(wave_data, sites_df, theme = "light")
Arguments
wave_data |
List. WAVE analysis results |
sites_df |
Data frame. Site information |
theme |
Character string. Visual theme for plot |
Value
ggplot object showing structural element comparison
Process Category Items
Description
Internal helper function to process WAVE category items
Usage
process_category_items(items, category_type)
Arguments
items |
List. Category items from WAVE results |
category_type |
Character string. Type of category being processed |
Value
Tibble containing processed item data
Validate WAVE Parameters
Description
Validates input parameters for WAVE API calls
Usage
validate_wave_params(input, api_key = NULL, report_type = 1)
Arguments
input |
Character vector. URLs or file paths |
api_key |
Character string. WAVE API key |
report_type |
Integer. WAVE report type |
Value
Logical TRUE if valid, stops with error if invalid
Access WebAIM WAVE Accessibility API
Description
This function provides an interface to the WebAIM WAVE accessibility evaluation API. It allows you to analyze web pages for accessibility issues and retrieve detailed reports.
Usage
wave(
key,
url,
format = NULL,
viewportwidth = NULL,
reporttype = NULL,
username = NULL,
password = NULL,
useragent = NULL,
toDataframe = FALSE,
file = NULL
)
Arguments
key |
Character string. Your WAVE API key |
url |
Character string. URL of the webpage to analyze |
format |
Character string. Response format (optional) |
viewportwidth |
Integer. Viewport width for analysis (optional) |
reporttype |
Integer. Type of report to generate (1-4) (optional) |
username |
Character string. Username for protected pages (optional) |
password |
Character string. Password for protected pages (optional) |
useragent |
Character string. Custom user agent (optional) |
toDataframe |
Logical. Whether to convert results to a data frame (default: FALSE) |
file |
Character string. Optional file path to save JSON results |
Value
List or tibble containing WAVE analysis results
Examples
## Not run:
# Basic usage
results <- wave(key = "your_api_key", url = "https://example.com")
# Get results as a data frame
df_results <- wave(key = "your_api_key", url = "https://example.com", toDataframe = TRUE)
# Save results to a temporary file
tmp_file <- file.path(tempdir(), "wave_results.json")
wave(key = "your_api_key", url = "https://example.com", file = tmp_file)
## End(Not run)