Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Nov 23, 2021
1 parent dfe2889 commit bf2c47c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 92 deletions.
6 changes: 5 additions & 1 deletion R/import-globalenv.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ import_globalenv_server <- function(id,
#' @importFrom utils data
#'
#' @examples
#' get_data_packages()
#' if (interactive()) {
#'
#' get_data_packages()
#'
#' }
get_data_packages <- function() {
suppressWarnings({
pkgs <- data(package = .packages(all.available = TRUE))
Expand Down
94 changes: 47 additions & 47 deletions examples/from-globalenv.R
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
if (interactive()) {
library(shiny)
library(datamods)

library(shiny)
library(datamods)

# Create some data.frames

my_df <- data.frame(
variable1 = sample(letters, 20, TRUE),
variable2 = sample(1:100, 20, TRUE)
)

results_analysis <- data.frame(
id = sample(letters, 20, TRUE),
measure = sample(1:100, 20, TRUE),
response = sample(1:100, 20, TRUE)
)


# Application

ui <- fluidPage(
fluidRow(
column(
width = 4,
import_globalenv_ui("myid")
),
column(
width = 8,
tags$b("Import status:"),
verbatimTextOutput(outputId = "status"),
tags$b("Name:"),
verbatimTextOutput(outputId = "name"),
tags$b("Data:"),
verbatimTextOutput(outputId = "data")
# Create some data.frames

my_df <- data.frame(
variable1 = sample(letters, 20, TRUE),
variable2 = sample(1:100, 20, TRUE)
)

results_analysis <- data.frame(
id = sample(letters, 20, TRUE),
measure = sample(1:100, 20, TRUE),
response = sample(1:100, 20, TRUE)
)


# Application

ui <- fluidPage(
fluidRow(
column(
width = 4,
import_globalenv_ui("myid")
),
column(
width = 8,
tags$b("Import status:"),
verbatimTextOutput(outputId = "status"),
tags$b("Name:"),
verbatimTextOutput(outputId = "name"),
tags$b("Data:"),
verbatimTextOutput(outputId = "data")
)
)
)
)

server <- function(input, output, session) {
server <- function(input, output, session) {

imported <- import_globalenv_server("myid")
imported <- import_globalenv_server("myid")

output$status <- renderPrint({
imported$status()
})
output$name <- renderPrint({
imported$name()
})
output$data <- renderPrint({
imported$data()
})
output$status <- renderPrint({
imported$status()
})
output$name <- renderPrint({
imported$name()
})
output$data <- renderPrint({
imported$data()
})

}
}

if (interactive())
shinyApp(ui, server)
}
6 changes: 5 additions & 1 deletion man/get_data_packages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 43 additions & 43 deletions man/import-globalenv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf2c47c

Please sign in to comment.