Skip to content
Snippets Groups Projects
Verified Commit f0a25082 authored by jens.preussner's avatar jens.preussner :ghost:
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
^.*\.Rproj$
^\.Rproj\.user$
.Rproj.user
.Rhistory
.RData
.Ruserdata
.DS_store
Package: i2dash
Type: Package
Title: Iterative and Interactive Dashboards in R
Version: 0.1.0
Authors@R: c(
person(given = "Arsenij", family = "Ustjanzew", email = "arsenij.ustjanzews@mpi-bn.mpg.de", role = c("aut", "cre")),
person(given = "Jens", family = "Preussner", email = "jens.preussner@mpi-bn.mpg.de", role = c("aut"), comment = c(ORCID = "0000-0003-1927-3458")),
person(given = "Mario", family = "Looso", email = "mario.looso@mpi-bn.mpg.de", role = "aut"))
Description: Iteratively create interactive flexdashboards in R.
Use four spaces when indenting paragraphs within the Description.
License: MIT
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Imports:
knitr,
flexdashboard
# Generated by roxygen2: do not edit by hand
export("%>%")
exportClasses(i2dashboard)
exportMethods(add_component)
exportMethods(add_page)
importFrom(magrittr,"%>%")
setGeneric("add_component", function(object, ...) standardGeneric("add_component"))
#' Method to add a component to a page of an i2dashboard object
#'
#' @param object A \linkS4class{i2dash::i2dashboard} object.
#' @param page The name of the page to add the component to.
#' @param component The name of the component.
#' @param ... Additional parameters passed to the components render function.
#'
#' @rdname idashboard-class
#' @export
setMethod("add_component", "i2dashboard", function(object, page, component, ...) {
pn <- strsplit(component, "::")[[1]]
eval_function <- if(length(pn) == 1) {
get(paste0("render_", pn[[1]]), envir = asNamespace("i2dash"), mode = "function")
} else {
get(paste0("render_", pn[[2]]), envir = asNamespace(pn[[1]]), mode = "function")
}
component <- do.call(eval_function, args = list(...))
object@pages[[page]]$components <- append(object@pages[[page]]$components, component)
return(object)
})
#' The idashboard S4 class
#'
#' @slot title The dashboards title
#' @slot pages A list of dashboard pages
#'
#' @name idashboard-class
#' @rdname idashboard-class
#' @export
i2dashboard <- setClass("i2dashboard",
slots = c(title = "character", pages = "list"))
setMethod("show", "i2dashboard", function(object) {
cat("A flexdashboard with the title: ", object@title, "\n", sep = "")
if(length(object@pages) > 0) {
cat("... containing ", length(object@pages), "pages.")
} else {
cat("... containing 0 pages.")
}
})
#' Sanitize component names
#'
#' This function takes a character string, replaces spaces by underscores and runs make.names.
#'
#' @param x A character string.
#'
#' @return A sanitized string.
.create_page_name <- function(x) {
x %>% tolower %>% gsub(x = ., pattern = " ", replacement = "_") %>% make.names %>% return
}
setGeneric("add_page", function(object, ...) standardGeneric("add_page"))
#' Method to add a page to an i2dashboard object
#'
#' @param object A \linkS4class{i2dash::i2dashboard} object.
#' @param page The name of the page to be added.
#' @param title The title of the page to be added.
#' @param layout The page layout (see below).
#' @param menu The name of the menu, under which the page should appear.
#'
#' @rdname idashboard-class
#' @export
setMethod("add_page", "i2dashboard", function(object, page, title, layout = "storyboard", menu = title, ...) {
name <- .create_page_name(page)
object@pages[[name]] <- list(title = title, layout = layout, menu = menu, components = list())
return(object)
})
setGeneric("remove_page", function(object, ...) standardGeneric("remove_page"))
setMethod("remove_page", "i2dashboard", function(object, page) {
name <- .create_page_name(page)
object@pages[[name]] <- NULL
return(object)
})
\ No newline at end of file
#' magrittr forward-pipe operator
#'
#' See \code{\link[magrittr]{\%>\%}}.
#' @name %>%
#' @importFrom magrittr %>%
#' @export %>%
NULL
\ No newline at end of file
#' Renders a textbox with arbitrary content
#'
#' @param title The title of the textbox
#' @param content The content of the textbox
#'
#' @return A string containing markdown code for the rendered textbox
render_textbox <- function(title, content) {
knitr::knit_expand(file = system.file("templates", "textbox.Rmd", package = "i2dash"), title = title, content = content)
}
\ No newline at end of file
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
### {{ title }}
{{ content }}
\ No newline at end of file
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pages.R
\name{.create_page_name}
\alias{.create_page_name}
\title{Sanitize component names}
\usage{
.create_page_name(x)
}
\arguments{
\item{x}{A character string.}
}
\value{
A sanitized string.
}
\description{
This function takes a character string, replaces spaces by underscores and runs make.names.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reexports.R
\name{\%>\%}
\alias{\%>\%}
\title{magrittr forward-pipe operator}
\description{
See \code{\link[magrittr]{\%>\%}}.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/components.R, R/i2dashboard.R, R/pages.R
\docType{methods}
\name{add_component,i2dashboard-method}
\alias{add_component,i2dashboard-method}
\alias{idashboard-class}
\alias{i2dashboard}
\alias{add_page,i2dashboard-method}
\title{Method to add a component to a page of an i2dashboard object}
\usage{
\S4method{add_component}{i2dashboard}(object, page, component, ...)
\S4method{add_page}{i2dashboard}(object, page, title,
layout = "storyboard", menu = title, ...)
}
\arguments{
\item{object}{A \linkS4class{i2dash::i2dashboard} object.}
\item{page}{The name of the page to add the component to.}
\item{component}{The name of the component.}
\item{...}{Additional parameters passed to the components render function.}
\item{title}{The title of the page to be added.}
\item{layout}{The page layout (see below).}
\item{menu}{The name of the menu, under which the page should appear.}
\item{object}{A \linkS4class{i2dash::i2dashboard} object.}
\item{page}{The name of the page to be added.}
}
\description{
Method to add a component to a page of an i2dashboard object
The idashboard S4 class
Method to add a page to an i2dashboard object
}
\section{Slots}{
\describe{
\item{\code{title}}{The dashboards title}
\item{\code{pages}}{A list of dashboard pages}
}}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/textbox.R
\name{render_textbox}
\alias{render_textbox}
\title{Renders a textbox with arbitrary content}
\usage{
render_textbox(title, content)
}
\arguments{
\item{title}{The title of the textbox}
\item{content}{The content of the textbox}
}
\value{
A string containing markdown code for the rendered textbox
}
\description{
Renders a textbox with arbitrary content
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment