https://github.com/emanuelhuber/testcolourpicker
Package to test the utilisation of colourpicker in a package
https://github.com/emanuelhuber/testcolourpicker
Last synced: 3 months ago
JSON representation
Package to test the utilisation of colourpicker in a package
- Host: GitHub
- URL: https://github.com/emanuelhuber/testcolourpicker
- Owner: emanuelhuber
- Created: 2023-02-05T15:03:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-05T16:33:09.000Z (over 2 years ago)
- Last Synced: 2025-01-05T13:10:35.993Z (4 months ago)
- Language: R
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# test_colourpicker
Package to test the utilization of `colourpicker` in a package
# Run the package
## Does not work
```r
if(!require("devtools")) install.packages("devtools")
devtools::install_github("emanuelhuber/testcolourpicker")
library(testcolourpicker)
testcolourpicker::runApp()```
## Workaround 1**Use the dev version from github**
```r
if(!require("devtools")) install.packages("devtools")
devtools::install_github("daattali/colourpicker")
devtools::install_github("emanuelhuber/nimoT")
# library(shiny)
# library(colourpicker)
library(nimoT)addResourcePath("colourpicker-lib/js",
system.file("www/shared/colourpicker/js", package="colourpicker"))
addResourcePath("colourpicker-lib/css",
system.file("www/shared/colourpicker/css",package="colourpicker"))
addResourcePath("colourpicker-binding",
system.file("srcjs",package="colourpicker"))runNimoT()
```## Workaround 2
**Restart R**
```r
if(!require("devtools")) install.packages("devtools")
devtools::install_github("emanuelhuber/testcolourpicker")
library(testcolourpicker)shiny::addResourcePath("colourpicker-lib/js",
system.file("www/shared/colourpicker/js", package="colourpicker"))
shiny::addResourcePath("colourpicker-lib/css",
system.file("www/shared/colourpicker/css",package="colourpicker"))
shiny::addResourcePath("colourpicker-binding",
system.file("srcjs",package="colourpicker"))
testcolourpicker::runApp()```
# Run the functions
**Restart R**
```r
library(shiny)
library(colourpicker)# Define UI for application that draws a histogram
shinyAppUI <- fluidPage(# Application title
titlePanel("Old Faithful Geyser Data"),# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
colourpicker::colourInput(inputId = "col", label = "Farbe 1", value = "#266939"),
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)# Define server logic required to draw a histogram
shinyAppServer <- function(input, output) {output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = input$col, border = 'white')
})
}# # Run the application
shinyApp(ui = shinyAppUI, server = shinyAppServer)```