README.md

gior-base

This is the base of gior for you to easily follow along the how to build htmlwidgets blogpost and build the htmlwidget for gio.js yourself!

  1. Get Started
  2. Historic
  3. Changes
  4. Data
  5. Package

Get Started

Clone this repository with git clone https://github.com/JohnCoene/base-gior.git, or, from RStudio:

  1. go to File
  2. Click on New Project
  3. Select Version Control
  4. Then select Git
  5. And paste the URL (https://github.com/JohnCoene/base-gior.git) under Repository URL
  6. Finally, click Create Project.

Historic

Here are the only functions that were ran:

  1. devtools::create("gior")
  2. htmlwiidgets::scaffoldWidget("gior")

Essentially creating a package with devtools and scaffolding the htmlwidget from the root of the package. You should be familiar with the first function. The second function essentially builds the following:

R/
| gior.R

inst/
|-- htmlwidgets/
|   |-- gior.js
|   |-- gior.yaml

Changes

Simply for convenience and for one to quickly get on with building the widget, some files were already edited or added.

DESCRIPTION

Edited some meta information that you should change and added necessary Imports:

  1. htmlwidgets
  2. shiny
  3. jsonlite

YML

The gior.yml file located in the inst folder was edited from:

# (uncomment to add a dependency)
# dependencies:
#  - name:
#    version:
#    src:
#    script:
#    stylesheet:

to

dependencies:
 - name: three
   version: 97
   src: htmlwidgets/lib/three
   script: three.min.js
 - name: gio
   version: 2.0
   src: htmlwidgets/lib/gio-2.0
   script: gio.min.js

The blogpost explains what this file does.

lib

The lib directory (and its sub directories); we essentially added the dependencies (that are referred to in the YML section above)

R/
| gior.R

inst/
|-- htmlwidgets/
|   |-- gior.js
|   |-- gior.yaml
|   |-- lib/
|   |   |-- gio-2.0/
|   |   |   |-- gio.min.js
|   |   |-- three/
|   |   |   |-- three.min.js

Data

The package also includes random data for you to test your package which can be loaded with data("country_data").

Package

This is a package, remember that to see changes reflected you will have to run:

  1. devtools::document()
  2. Thendevtools::install() or CTRL/CMD + SHIFT + B from RStudio.

Note that, as is, the package works but does not pass R CMD Check.



JohnCoene/base-gior documentation built on March 6, 2021, 10:54 a.m.