Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information
uribo committed Jan 22, 2020
0 parents commit 6ece26199282044f60181f381c9c452c9eeb95c5
Showing with 1,235 additions and 0 deletions.
  1. +14 −0 .Rbuildignore
  2. +1 −0 .Rprofile
  3. +34 −0 .github/workflows/pkgdown.yml
  4. +4 −0 .gitignore
  5. +28 −0 DESCRIPTION
  6. +18 −0 Dockerfile
  7. +2 −0 LICENSE
  8. +21 −0 LICENSE.md
  9. +5 −0 NAMESPACE
  10. +30 −0 R/stat_map.R
  11. +11 −0 R/utils-pipe.R
  12. +13 −0 docker-compose.yml
  13. +21 −0 easyestat.Rproj
  14. +19 −0 man/download_stat_map.Rd
  15. +12 −0 man/pipe.Rd
  16. +27 −0 pkgdown.yml
  17. +782 −0 renv.lock
  18. +3 −0 renv/.gitignore
  19. +185 −0 renv/activate.R
  20. +5 −0 renv/settings.dcf
@@ -0,0 +1,14 @@
^renv$
^renv\.lock$
^easyestat\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^_pkgdown\.yml$
^docs$
^pkgdown$
^Dockerfile$
^docker-compose\.yml$
^\.env$
^pkgdown\.yml$
^\.Rprofile$
^\.github$
@@ -0,0 +1 @@
source("renv/activate.R")
@@ -0,0 +1,34 @@
on:
push:
branches: master

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
steps:
- uses: actions/checkout@master

- uses: r-lib/actions/setup-r@master

- uses: r-lib/actions/setup-pandoc@master

- uses: actions/cache@v1
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Application Support/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Install Package Dependencies
run: |-
Rscript -e "install.packages('renv')"
Rscript -e "renv::restore(confirm = FALSE)"
- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
Rscript -e "pkgdown:::deploy_local(new_process = FALSE, remote_url = 'https://x-access-token:${{secrets.GITHUB_PAT}}@github.com/${{github.repository}}.git')"
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
docs/
.env
@@ -0,0 +1,28 @@
Package: easyestat
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person(given = "Shinya",
family = "Uryu",
role = c("aut", "cre"),
email = "suika1127@gmail.com",
comment = c(ORCID = "0000-0002-0493-6186"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
Imports:
dplyr (>= 0.8.3),
glue (>= 1.3.1),
httr (>= 1.4.1),
magrittr (>= 1.5),
purrr (>= 0.3.3),
rlang (>= 0.4.2),
stringr (>= 1.4.0)
Suggests:
devtools (>= 2.2.1),
pkgdown (>= 1.4.1.9000)
LazyData: true
URL: https://github.com/uribo/easyestat
BugReports: https://github.com/uribo/easyestat/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2
@@ -0,0 +1,18 @@
FROM rocker/rstudio:3.6.2

RUN set -x && \
apt-get update && \
apt-get install -y --no-install-recommends \
libmagick++-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ARG GITHUB_PAT

RUN set -x && \
echo "GITHUB_PAT=$GITHUB_PAT" >> /usr/local/lib/R/etc/Renviron

RUN set -x && \
install2.r --error --skipinstalled --repos 'http://mran.revolutionanalytics.com/snapshot/2020-01-15' \
renv && \
rm -rf /tmp/downloaded_packages/ /tmp/*.rds
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Shinya Uryu
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2020 Shinya Uryu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(download_stat_map)
importFrom(magrittr,"%>%")
@@ -0,0 +1,30 @@
#' Download Japan prefecture map from e-stat
#' @param prefcode jis code for prefecture and city identifical number. If prefecture, must be from 1 to 47.
#' @param dest If TRUE, to unzip downloaded files.
#' @inheritParams utils::unzip
#' @export
download_stat_map <- function(prefcode, exdir = ".", dest = TRUE) {
prefcode <-
stringr::str_pad(prefcode, width = 2, pad = "0")
rlang::arg_match(prefcode, values = stringr::str_pad(seq.int(47), width = 2, pad = "0"))
x <-
glue::glue(
"https://www.e-stat.go.jp/gis/statmap-search/data?dlserveyId=A002005212015&code={prefcode}&coordSys=1&format=shape&downloadType=5"
)
qry <-
purrr::pluck(httr::parse_url(x), "query")
destfile <-
glue::glue(
"{exdir}/{serveyId}{coordSys}{prefcode}.zip",
serveyId = qry$dlserveyId,
coordSys = dplyr::case_when(qry$coordSys == "1" ~ "DDSWC")
)
utils::download.file(url = x,
destfile = destfile)
if (dest == TRUE) {
utils::unzip(
zipfile = destfile,
exdir = glue::glue("{tools::file_path_sans_ext(destfile)}")
)
}
}
@@ -0,0 +1,11 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL
@@ -0,0 +1,13 @@
version: "3.7"
services:
rstudio:
build:
context: "."
args:
- GITHUB_PAT=${GITHUB_PAT}
ports:
- "8787:8787"
volumes:
- ".:/home/rstudio/easyestat"
environment:
PASSWORD: ${PASSWORD}
@@ -0,0 +1,21 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,27 @@
url: https://uribo.github.io/easyestat

authors:
Shinya Uryu:
href: https://suryu.me

templates:
params:
bootswatch: paper

development:
mode: auto

navbar:
type: default
left:
- icon: fa-home fa-lg
href: index.html
- text: Reference
href: reference/index.html
- text: News
href: news/index.html

reference:
- title: "map"
contents:
- download_stat_map

0 comments on commit 6ece261

Please sign in to comment.
You can’t perform that action at this time.