Skip to content

Commit 1bbb5b9

Browse files
committed
golem base build
1 parent e5720e8 commit 1bbb5b9

11 files changed

Lines changed: 186 additions & 9 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Imports:
1515
htmltools
1616
Encoding: UTF-8
1717
LazyData: true
18-
RoxygenNote: 6.1.1
18+
RoxygenNote: 7.1.1
1919
URL: https://github.com/webscale/shVis
2020
BugReports: https://github.com/webscale/shVis/issues

NAMESPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ importFrom(golem,add_resource_path)
77
importFrom(golem,bundle_resources)
88
importFrom(golem,favicon)
99
importFrom(golem,with_golem_options)
10+
importFrom(htmltools,HTML)
11+
importFrom(htmltools,tagAppendAttributes)
12+
importFrom(htmltools,tagList)
13+
importFrom(htmltools,tags)
14+
importFrom(shiny,NS)
15+
importFrom(shiny,column)
1016
importFrom(shiny,shinyApp)
17+
importFrom(shiny,tagList)

R/fct_helpers.R

Whitespace-only changes.

R/mod_dt_edit_mod.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#' dt_edit_mod UI Function
2+
#'
3+
#' @description A shiny Module.
4+
#'
5+
#' @param id,input,output,session Internal parameters for {shiny}.
6+
#'
7+
#' @noRd
8+
#'
9+
#' @importFrom shiny NS tagList
10+
mod_dt_edit_mod_ui <- function(id){
11+
ns <- NS(id)
12+
tagList(
13+
14+
)
15+
}
16+
17+
#' dt_edit_mod Server Function
18+
#'
19+
#' @noRd
20+
mod_dt_edit_mod_server <- function(input, output, session){
21+
ns <- session$ns
22+
23+
}
24+
25+
## To be copied in the UI
26+
# mod_dt_edit_mod_ui("dt_edit_mod_ui_1")
27+
28+
## To be copied in the server
29+
# callModule(mod_dt_edit_mod_server, "dt_edit_mod_ui_1")
30+

R/utils_helpers.R

Whitespace-only changes.

data-raw/my_dataset.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## code to prepare `my_dataset` dataset goes here
2+
3+
usethis::use_data(my_dataset, overwrite = TRUE)

dev/02_dev.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ usethis::use_package( "thinkr" )
1919

2020
## Add modules ----
2121
## Create a module infrastructure in R/
22-
golem::add_module( name = "name_of_module1" ) # Name of the module
22+
golem::add_module( name = "dt_edit_mod" ) # Name of the module
2323
golem::add_module( name = "name_of_module2" ) # Name of the module
2424

2525
## Add helper functions ----

dev/DT_play.Rmd

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: "DT Play"
3+
author: "Niraj Juneja"
4+
date: "8/30/2020"
5+
output: html_document
6+
runtime: shiny
7+
---
8+
9+
```{r setup, include=FALSE}
10+
knitr::opts_chunk$set(echo = TRUE)
11+
```
12+
13+
This R Markdown document is made interactive using Shiny. Made as playground for lwarnign the DT package
14+
15+
To learn more, see [Interactive Documents](http://rmarkdown.rstudio.com/authoring_shiny.html).
16+
17+
## DT Table playground
18+
Play with DT
19+
20+
```{r dt-plan , echo=FALSE , message=FALSE}
21+
library(DT)
22+
iris2 = head(iris, 20)
23+
options(DT.options = list(pageLength = 5))
24+
# default Bootstrap style in DT
25+
#datatable(iris2, style = 'bootstrap')
26+
27+
datatable(head(iris), colnames = c('Here', 'Are', 'Some', 'New', 'Names'))
28+
29+
datatable(iris2, colnames = c('Here', 'Are', 'Some', 'New', 'Names') ,
30+
style = 'bootstrap', class = 'table-bordered')
31+
32+
33+
```
34+
35+
```{r}
36+
m = matrix(c(
37+
'<b>Bold</b>', '<em>Emphasize</em>', '<a href="http://rstudio.com">RStudio</a>',
38+
'<a href="#" onclick="alert(\'Hello World\');">Hello</a>'
39+
), 2)
40+
colnames(m) = c('<span style="color:red">Column 1</span>', '<em>Column 2</em>')
41+
datatable(m , escape = FALSE) # escape = TRUE by default
42+
```
43+
44+
45+
46+
```{r}
47+
library(shiny)
48+
49+
50+
51+
A <- c("Alpha", "Beta", "Gamma", "Delta")
52+
B <- c("one","two","three","four")
53+
C <- c("five","six","seven","eight")
54+
55+
56+
Test_File <- tibble::tibble("A" = A , "B" = B , "C" = C)
57+
58+
renderDataTable(
59+
data <- Test_File %>%
60+
dplyr::select(A,B) %>%
61+
dplyr::mutate(URL = paste0("https://www.testsite.com/abcdefg/", A))%>%
62+
dplyr::mutate(URL = paste0("<a href='", URL, "'>",A,"</a>"))
63+
, escape = FALSE)
64+
65+
66+
```
67+
68+
69+
## Inputs and Outputs
70+
71+
You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive by wrapping it in the Shiny `renderPlot` function. The `selectInput` and `sliderInput` functions create the input widgets used to drive the plot.
72+
73+
```{r eruptions, echo=FALSE}
74+
inputPanel(
75+
selectInput("n_breaks", label = "Number of bins:",
76+
choices = c(10, 20, 35, 50), selected = 20),
77+
78+
sliderInput("bw_adjust", label = "Bandwidth adjustment:",
79+
min = 0.2, max = 2, value = 1, step = 0.2)
80+
)
81+
82+
renderPlot({
83+
hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
84+
xlab = "Duration (minutes)", main = "Geyser eruption duration")
85+
86+
dens <- density(faithful$eruptions, adjust = input$bw_adjust)
87+
lines(dens, col = "blue")
88+
})
89+
```
90+
91+
## Embedded Application
92+
93+
It's also possible to embed an entire Shiny application within an R Markdown document using the `shinyAppDir` function. This example embeds a Shiny application located in another directory:
94+
95+
```{r tabsets, echo=FALSE}
96+
shinyAppDir(
97+
system.file("examples/06_tabsets", package = "shiny"),
98+
options = list(
99+
width = "100%", height = 550
100+
)
101+
)
102+
```
103+
104+
Note the use of the `height` parameter to determine how much vertical space the embedded application should occupy.
105+
106+
You can also use the `shinyApp` function to define an application inline rather then in an external directory.
107+
108+
In all of R code chunks above the `echo = FALSE` attribute is used. This is to prevent the R code within the chunk from rendering in the document alongside the Shiny components.
109+
110+
111+

dev/play.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library(DT)
2+
3+
xfun::session_info('DT')
4+
5+
datatable(iris, options = list(), class = "display",
6+
callback = JS("return table;"), rownames, colnames, container,
7+
caption = NULL, filter = c("none", "bottom", "top"), escape = TRUE,
8+
style = "default", width = NULL, height = NULL, elementId = NULL,
9+
fillContainer = getOption("DT.fillContainer", NULL),
10+
autoHideNavigation = getOption("DT.autoHideNavigation", NULL),
11+
selection = c("multiple", "single", "none"), extensions = list(),
12+
plugins = NULL, editable = FALSE)
13+
14+
15+
datatable(iris , style = 'bootstrap' , class = "table-hover")
16+
17+
18+
DT:::DT2BSClass('display')
19+
20+
DT:::DT2BSClass(c('compact', 'cell-border'))
21+
22+
library(DT)
23+
iris2 = head(iris, 20)
24+
options(DT.options = list(pageLength = 5))
25+
# default Bootstrap style in DT
26+
datatable(iris2, style = 'bootstrap')

inst/app/www/script.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$( document ).ready(function() {
2+
3+
});

0 commit comments

Comments
 (0)