Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements to Dataset Documentation and Wiki Generation for ZekDex #10

Merged
merged 20 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
^\.Rproj\.user$
^packing$
^data/.*\.csv$
^wiki$
^\.git
21 changes: 21 additions & 0 deletions .github/workflows/wiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update Wiki
on:
push:
paths:
- 'wiki/**'
branches:
- main

permissions:
contents: write

jobs:
update-wiki:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Push changes to Wiki
uses: OrlovM/Wiki-Action@v1
with:
path: 'wiki'
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ZekDex
Type: Package
Title: Comprehensive Pokémon Datasets from Bulbapedia
Version: 0.1.1
Version: 0.1.2
Author: ZekromVale
Maintainer: ZekromVale <[email protected]>
Description:
Expand All @@ -20,7 +20,7 @@ LazyData: true
Depends:
R (>= 4.1),
methods
Imports: dplyr, magrittr, purrr, readr, rlang, stringr, tibble, tidyr, glue, tidyselect, pkgload
Imports: dplyr, magrittr, purrr, readr, rlang, stringr, tibble, tidyr, glue, tidyselect, pkgload, ggplot2
Suggests: rvest, janitor, coro, xml2
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ export(filterByType)
export(filter_non_unique)
export(filter_non_unique_each)
export(fun)
export(gen_catch)
export(gen_evos)
export(gen_groups)
export(gen_height)
export(gen_lang)
export(gen_national)
export(gen_physicalAttr)
export(gen_reginal)
export(gen_stats)
export(gen_type)
export(gen_type_chart)
export(gen_weight)
export(ggtypes)
export(name_from_row)
export(non_unique)
export(paste_non_unique)
Expand Down Expand Up @@ -52,6 +55,7 @@ export(stab)
export(stab_multiplyer)
export(str_before_match)
export(str_longest_match)
export(type_colors)
import(methods)
importFrom(dplyr,across)
importFrom(dplyr,any_of)
Expand Down Expand Up @@ -79,6 +83,7 @@ importFrom(dplyr,select_if)
importFrom(dplyr,slice)
importFrom(dplyr,starts_with)
importFrom(dplyr,ungroup)
importFrom(ggplot2,scale_fill_manual)
importFrom(glue,glue)
importFrom(magrittr,"%>%")
importFrom(pkgload,is_loading)
Expand Down
2 changes: 1 addition & 1 deletion R/Util.R
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ save_data = function(
){
if(pkgload::is_loading()) return()
if(rda)save(list = sym, file = glue("{root}/{file}.rda"), envir = parent.frame()) # TODO compress
if(csv)write_csv(get(sym, envir = parent.frame()), glue("{root}/{file}.csv"))
if(csv)write_csv(get(sym, envir = parent.frame()), glue("{root}/{file}.csv"), quote = "all")
if(!csv&&!rda)warning("Nothing saved")
}

Expand Down
1 change: 1 addition & 0 deletions R/Weight.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ gen_height = function(write = FALSE, root = "data/", file = "PokemonHeight"){
#' @param fileHeight Character, the name of the file containing the height data.
#' @param fileWeight Character, the name of the file containing the weight data.
#' @return A data frame of physical attributes of Pokemon.
#' @export
gen_physicalAttr = function(write = FALSE, root = "data/", file = "PokemonPhysicalAttr", fileHeight = "PokemonHeight", fileWeight = "PokemonWeight"){
weight = gen_weight(write = write, root = root, file = fileWeight)
height = gen_height(write = write, root = root, file = fileHeight)
Expand Down
1 change: 1 addition & 0 deletions R/catch.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param root Character. The root directory where the file will be saved. Default is "data/".
#' @param file Character. The name of the file where the data will be saved. Default is "PokemonCatch".
#' @return A tibble of the scraped Pokémon data.
#' @export
#' @importFrom purrr map walk
#' @importFrom dplyr as_tibble select_if rename any_of rename_with mutate coalesce bind_rows
#' @importFrom tidyr separate
Expand Down
830 changes: 454 additions & 376 deletions R/data.R

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions R/gg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' Generate a list of color palettes for Pokémon types
#'
#' This function generates a list of color palettes for Pokémon types. The list contains two named vectors: 'new' and 'old', each representing a different color palette.
#'
#' @export
#' @return A list of named vectors representing color palettes for Pokémon types.
type_colors = (function(){
type_colors_types = c("Grass", "Fire", "Water", "Bug", "Normal", "Dark", "Poison", "Electric","Ground", "Ice", "Fairy", "Steel", "Fighting","Psychic", "Rock", "Ghost", "Dragon", "Flying", "Stellar", "???")
type_colors_old = c("#78C850", "#F08030", "#6890F0", "#A8B820", "#A8A878", "#705848", "#A040A0", "#F8D030", "#E0C068", "#98D8D8", "#EE99AC", "#B8B8D0", "#C03028", "#F85888", "#B8A038", "#705898", "#7038F8", "#A890F0","#364e71", "#4d7a70")
type_colors_new = c("#328121", "#af1415", "#0d55b0", "#748114", "#4e5457", "#4e3e3e", "#6b2a9a", "#c89a00", "#74411a", "#0a85a4", "#840f84", "#3a7083", "#cc6600", "#a10e3d", "#504c33", "#5a345a", "#192795", "#0f4579","#364e71", "#4d7a70")
list(
new = setNames(type_colors_new, type_colors_types),
old = setNames(type_colors_old, type_colors_types)
)
})()

#' Create a ggplot2 fill scale for Pokémon types
#'
#' This function creates a ggplot2 fill scale for Pokémon types using a specified color palette.
#'
#' @param types A named vector representing a color palette for Pokémon types. The names of the vector are the Pokémon types, and the values are the corresponding colors.
#'
#' @return A ggplot2 fill scale.
#' @export
#' @importFrom ggplot2 scale_fill_manual
ggtypes = function(
types = type_colors$new
){
# Return the scale_fill_manual call with the Pokémon type colors
scale_fill_manual(values = new)
}
Loading