Skip to content

Commit

Permalink
First version to pass check()
Browse files Browse the repository at this point in the history
  • Loading branch information
juba committed Jul 8, 2021
0 parents commit dffbd5e
Show file tree
Hide file tree
Showing 48 changed files with 39,132 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
^.*\.Rproj$
^\.Rproj\.user$
examples/
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
^srcjs$
^node_modules$
^package\.json$
^package-lock\.json$
^webpack\.dev\.js$
^webpack\.prod\.js$
^webpack\.common\.js$
^\.lintr$
^\.vscode$
^examples\.R$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
81 changes: 81 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches:
- master
pull_request:
branches:
- master

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.config.r }}

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-2-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-2-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
46 changes: 46 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches: master

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

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

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
docs
vignettes/*.html
.vscode/
node_modules
*.Rproj
4 changes: 4 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters: with_defaults(
line_length_linter = NULL,
object_name_linter = NULL
)
31 changes: 31 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Package: obsplot
Type: Package
Title: Observable Plot bindings
Version: 0.0.1
Date: 2021-07-01
Authors@R: c(
person(
"Julien", "Barnier",
email = "[email protected]",
role = c("aut", "cre")
))
Maintainer: Julien Barnier <[email protected]>
Description: Allows using Observable Plot library in R.
VignetteBuilder: knitr
URL: https://github.com/juba/obsplot
BugReports: https://github.com/juba/obsplot/issues
License: GPL (>=3)
Encoding: UTF-8
LazyData: true
Enhances: shiny
Imports:
htmlwidgets,
jsonlite,
purrr
Suggests:
palmerpenguins,
knitr,
rmarkdown,
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)

66 changes: 66 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated by roxygen2: do not edit by hand

export(facet)
export(mark_area)
export(mark_areaX)
export(mark_areaY)
export(mark_barX)
export(mark_barY)
export(mark_cell)
export(mark_cellX)
export(mark_cellY)
export(mark_dot)
export(mark_dotX)
export(mark_dotY)
export(mark_frame)
export(mark_line)
export(mark_lineX)
export(mark_lineY)
export(mark_link)
export(mark_rect)
export(mark_rectX)
export(mark_rectY)
export(mark_ruleX)
export(mark_ruleY)
export(mark_text)
export(mark_textX)
export(mark_textY)
export(mark_tickX)
export(mark_tickY)
export(obsplot)
export(obsplotOutput)
export(opts)
export(renderObsplot)
export(scale_color)
export(scale_opacity)
export(scale_radius)
export(scale_x)
export(scale_y)
export(style)
export(transform_bin)
export(transform_binX)
export(transform_binY)
export(transform_group)
export(transform_groupX)
export(transform_groupY)
export(transform_groupZ)
export(transform_map)
export(transform_mapX)
export(transform_mapY)
export(transform_normalizeX)
export(transform_normalizeY)
export(transform_selectFirst)
export(transform_selectLast)
export(transform_selectMaxX)
export(transform_selectMaxY)
export(transform_selectMinX)
export(transform_selectMinY)
export(transform_stackX)
export(transform_stackX1)
export(transform_stackX2)
export(transform_stackY)
export(transform_stackY1)
export(transform_stackY2)
export(transform_windowX)
export(transform_windowY)
import(htmlwidgets)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# obsplot 0.0.1

* First version
109 changes: 109 additions & 0 deletions R/channels.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
check_channels <- function(data, mark_channels, mark_args) {
universal_channels <- data.frame(
channel = c("fill", "fillOpacity", "stroke", "strokeOpacity"),
status = c("opt", "opt", "opt", "opt"),
type = c("color", "opacity", "color", "opacity")
)
channels <- rbind(mark_channels, universal_channels)

# Is there a transform argument ?
has_transform <- !is.null(mark_args[["transform"]])

# Check required channels
if (!has_transform) {
req <- channels$channel[channels$status == "req"]
missing_channels <- setdiff(req, names(mark_args))
if (length(missing_channels) > 1) {
stop("missing channels ", paste(missing_channels, collapse = ", "))
}
}

# Don't check a channel if it is a JS function
mark_args <- Filter(function(mark_arg) {
!inherits(mark_arg, "JS_EVAL")
}, mark_args)

args <- names(mark_args)

# Check numeric channels
chans <- intersect(args, channels$channel[channels$type == "num"])
for (chan in chans) {
check_channel_numeric(data, chan, mark_args[[chan]])
}

# Check categorical channels
chans <- intersect(args, channels$channel[channels$type == "cat"])
for (chan in chans) {
check_channel_categorical(data, chan, mark_args[[chan]])
}

# Check color channels
chans <- intersect(args, channels$channel[channels$type == "color"])
for (chan in chans) {
check_channel_color(data, chan, mark_args[[chan]])
}

# Check opacity channels
chans <- intersect(args, channels$channel[channels$type == "opacity"])
for (chan in chans) {
check_channel_opacity(data, chan, mark_args[[chan]])
}

# Check radius channels
chans <- intersect(args, channels$channel[channels$type == "radius"])
for (chan in chans) {
check_channel_radius(data, chan, mark_args[[chan]])
}
}


check_channel_numeric <- function(data, chan, value) {
# Numeric vector
if (length(value) > 1 && !is.numeric(value)) {
stop(chan, " must be numeric")
}
# Numeric column of data
if (length(value) == 1) {
if (!(value %in% names(data))) stop(chan, " must be a column of data")
if ((value %in% names(data)) && !is.numeric(data[[value]])) {
stop(chan, " must be a numeric column of data")
}
}
}

check_channel_categorical <- function(data, chan, value) {
# Categorical vector
if (length(value) > 1 && !is_categorical(value)) {
stop(chan, " must be categorical")
}
# Categorical column of data
if (length(value) == 1) {
if (!(value %in% names(data))) stop(chan, " must be a column of data")
if ((value %in% names(data)) && !is_categorical(data[[value]])) {
stop(chan, " must be a categorical column of data")
}
}
}

check_channel_color <- function(data, chan, value) {
# If single string, either a CSS color or a column of data
if (length(value) == 1 && is.character(value)) {
if (!(is_css_color(value) || value %in% names(data))) {
stop(chan, " must be a CSS color or a column of data")
}
}
}

check_channel_opacity <- function(data, chan, value) {
# If single string, must be a column of data
if (length(value) == 1 && is.character(value)) {
if (!(value %in% names(data))) stop(chan, " must be a column of data")
}
}

check_channel_radius <- function(data, chan, value) {
# If single string, must be a column of data
if (length(value) == 1 && is.character(value)) {
if (!(value %in% names(data))) stop(chan, " must be a column of data")
}
}
11 changes: 11 additions & 0 deletions R/facet.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' Add a facet to an obsplot
#'
#' @param g an obsplot object
#' @param data optional data
#' @param ... options passed to define the facet
#' @export

facet <- function(g, data = NULL, ...) {
g$x$facet <- list(data = data, opts = list(...))
g
}
Loading

0 comments on commit dffbd5e

Please sign in to comment.