-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
206 lines (141 loc) · 5.07 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[![R build status](https://github.com/ThinkR-open/shinipsum/workflows/R-CMD-check/badge.svg)](https://github.com/ThinkR-open/shinipsum/actions)
[![Codecov test coverage](https://codecov.io/gh/ThinkR-open/shinipsum/branch/master/graph/badge.svg)](https://codecov.io/gh/ThinkR-open/shinipsum?branch=master)
[![R-CMD-check](https://github.com/ThinkR-open/shinipsum/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/shinipsum/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
# shinipsum <img src="https://raw.githubusercontent.com/ThinkR-open/shinipsum/master/img/thinkr-hex-shinipsum.png" align="right" alt="" width="120" />
The goal of `{shinipsum} `is to provide random shiny elements for easiest shiny app prototyping, so that you can focus on building the frontend before building the backend.
The full documentation can be found on the `{pkgdown} `site: <https://thinkr-open.github.io/shinipsum/>
## Installation
You can install the dev version of shinipsum from GitHub with:
``` r
install.packages("shinipsum")
```
## About
You're reading the doc about version : `r pkgload::pkg_version()`
This README has been compiled on the
```{r}
Sys.time()
```
Here are the test & coverage results :
```{r}
devtools::check(quiet = TRUE)
```
```{r echo = FALSE}
unloadNamespace("shinipsum")
```
```{r}
covr::package_coverage()
```
## Demo
Available examples:
```{r}
library(shinipsum)
ipsum_examples()
```
You can run `{shinipsum}` demos with:
```{r eval = FALSE}
shiny::runApp(
ipsum_examples("01_navbar.R")
)
```
## Available ipsums :
> Note: {shinipsum} only load functions which are necessary to its internal job. If you want to customise an output or to use a renderXX / XXOutput, you'll need to **explicitely** load the packages needed (for example, if you want to customise a dygraph, a ggplot, or use ggplotly).
### DataTable
`random_DT` takes 4 args :
+ `nrow` & `ncol`: number of row and columns of the table
+ `type` : random, numeric, character, numchar - the type of the columns
+ `...` : args to be passed to `DT::datatable`
### Image
`random_image` returns a random image.
### Plot
`random_ggplot` takes one arg :
+ `type` : Can be any of "random", "point", "bar", "boxplot","col", "tile", "line", "bin2d", "contour", "density", "density_2d", "dotplot", "hex", "freqpoly", "histogram", "ribbon", "raster", "tile", "violin" and defines the geom of the ggplot. Default is "random", and chooses a random geom for you.
Default theme is minimal.
As the return object is a `ggplot`, it can be enhanced like any other ggplot with `+`.
```{r eval = FALSE}
library(ggplot2)
random_ggplot(type = "col") +
labs(title = "Random plot") +
theme_bw()
```
`random_ggplotly` calls the `ggplotly` function on a `random_ggplot`.
### Dygraph
`random_dygraph` returns a random dygprah. It takes one arg:
+ `...`: arguments which are passed to the `dygraph()` function.
As the return object is a `dygraph`, it can be enhanced like any other dygraph.
```{r eval = FALSE}
library(dygraphs)
random_dygraph() %>%
dyRangeSelector()
```
### Print
`random_print` takes one arg:
+ `type`: can be any of `"character", "numeric", "model", "table"`, and defines the type of print. Default is `"character"`.
### Table
`random_table` takes three args : `nrow`, `ncols` and `type`. See `random_DT`.
### Text
`random_text` takes one of these two args:
+ `nchar`: lorem ipsum of `nchar` characters
+ `nwords`: lorem ipsum of `nwords` characters
+ `offset`: number of characters or words to offset the result by
### Lm
`random_lm` returns a random `lm` model output:
+ `nobs`: Number of observations
+ `nx`: Number of variables (should be lower than `nobs`)
## Example
Here is an example of using `{shinipsum}` to generate a random app:
```{r eval = FALSE}
library(shiny)
library(shinipsum)
library(DT)
ui <- fluidPage(
h2("A Random DT"),
DTOutput("data_table"),
h2("A Random Image"),
plotOutput("image", height = "300px"),
h2("A Random Plot"),
plotOutput("plot"),
h2("A Random Print"),
verbatimTextOutput("print"),
h2("A Random Table"),
tableOutput("table"),
h2("A Random Text"),
tableOutput("text")
)
server <- function(input, output, session) {
output$data_table <- DT::renderDT({
random_DT(10, 5)
})
output$image <- renderImage({
random_image()
})
output$plot <- renderPlot({
random_ggplot()
})
output$print <- renderPrint({
random_print("model")
})
output$table <- renderTable({
random_table(10, 5)
})
output$text <- renderText({
random_text(nwords = 50)
})
}
shinyApp(ui, server)
```
<img src="https://raw.githubusercontent.com/ThinkR-open/shinipsum/master/img/shinipsum.png">
Please note that the 'shinipsum' project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.