-
Notifications
You must be signed in to change notification settings - Fork 2
/
misc.R
91 lines (83 loc) · 2.1 KB
/
misc.R
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
#' Generate a row div
#'
#' A simple row div
#'
#' @param ... The elements to include within the body of the row
#'
#' @return An HTML containing elements of a container with class row to be embedded in a page
#' @examples
#' row(shiny::div(width=12,"Hello nextGenShinyApps"))
#' @export
#'
row <- function(...) {
div(class = "row", ...)
}
#' Include stylesheets and scripts
#'
#' Use the package scripts and stylesheets in a page
#'
#' @param template The template type
#' @param color The numeric style of template
#'
#' @return A list of files to be inserted in the header of a page
#' @examples
#' cssjsinclude('core','3')
#' @export
#'
cssjsinclude <- function(template,color){
assign('.nGSAscripts',TRUE)
htmltools::htmlDependency(
"nextGenShinyApps", "2.0",
src = template.loc(template),
script = c("nextgenshinyapps.js"),
stylesheet = c("nextgenshinyapps.css", paste0("cust-theme-",color,".css")),
all_files = FALSE
)
}
#' Nav tag
#'
#' A nav tag for creating HTML navigations
#'
#' @param class The class of the navigation container
#' @param id The identification of the navigation container
#' @param role The character role of the container on the page
#' @param ... The content of the container
#'
#' @return HTML content of a container with type nav
#' @examples
#' nav('sample','id1','sample','some content')
#' @export
#'
nav <- function(class, id = NULL, role = NULL, ...) {
HTML(paste0("<nav class='", class, "' id='", id, "' role='", role, "'>", ..., "</nav>"))
}
#' Template location full text
#'
#' Fetch the location of the scripts
#'
#' @param template The type of template to fetch
#'
#' @return A path for the location of the package
#' @examples
#' template.loc('core')
#' @export
#'
template.loc <- function(template = "core"){
file.path(find.package(package = "nextGenShinyApps"),template)
}
#' Random number betwen 1 and 10000
#'
#' One or more random numbers
#'
#' @param num The number of numbers to return
#'
#' @return One or more numbers
#' @examples
#' rand.num(10)
#' @export
#'
rand.num <- function(num){
sample(1:10000, num)
}
rand.sc13 <-
as.character(sample(1:13,13))