Getting started

Getting started with the card.pro R package is very easy. With an R executable already install, navigate to the console and install the card.pro package. Next, load the card.pro library, and begin using it.

This project is hosted directly on GitHub and be accessed with these links

Star project

Watch updates

Issue tracker

Download repository

Fork

1. Below are some steps to follow on getting started and an example code to run.

# option1: install from CRAN
install.packages("card.pro")

# option2: install from CRAN github page
remotes::install_github("cran/card.pro")

# option3: install from my github page (note that this version is constantly being developed)
remotes::install_github("oobianom/card.pro")

2. Load the library and start with a simple code

library(shiny)
library(card.pro)

# Create UI & server
ui <- fluidPage(
  use.cardpro(theme = "a", fix.header = TRUE),
  titlePanel("card.pro: drag, resize, rearrage, fullscreen and refresh. your settings preserved!"),
  moveable(
    card.pro(
      title = "Sample setup panel",
      width = 3,
      header.bg = "blue",
      colorbtn = FALSE,
      editbtn = FALSE,
      tabs = list(
        tabEntry(
          "Main",
          sliderInput("bins",
                      "Number of bins:",
                      min = 1,
                      max = 50,
                      value = 30
          )
        ),
        tabEntry(
          "Values",
          textInput("nor1", "Enter name"), "Content for 1",
          textInput("nor1", "Enter name"), "Content for 1",
          actionButton("nor1", "Try click"), "sample"
        )
      ),
      
      #other contents
      "This is the setup",
      
    ),
    card.pro(
      plotOutput("distPlot"),
      plotOutput("distPlot2"),
      xtra.header.content = div(class="c-red","Downloading graph..."),
      sidebar = div(
        "Plot settings",
        textInput("testy", "Y-axis title", "Concentration"),
        textInput("testx", "X-axis title", "Time"),
        textInput("dpi", "Image dpi", "300"),
        textInput("strp", "Subset", "NA"),
        actionButton("test3", "Re-graph")
      ),
      title = "Plot output",
      width = 6,
      header.bg = "yellow",
    ),
    card.pro(
      tableOutput("table1"),
      title = "Summary table",
      width = 3,
      header.bg = "red",
      footer = "Here is a sample footer for descriptions"
    )
  )
)

server <- function(input, output) {
  output$table1 <- renderTable({
    head(mtcars)
  })
  
  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 = "darkgray", border = "white",
         xlab = input$testx,
         main = input$testy
    )
  })
  output$distPlot2 <- renderPlot({
    # generate bins based on input$bins from ui.R
    x <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    plot(bins,quickcode::number(length(bins)))
  })
}
# Run the application
shinyApp(ui = ui, server = server)