본문 바로가기
언어/R

shiny web 2

by newlibra 2024. 11. 1.

 

 

 

 

 

<server.R>

library(shiny)
# Define Server Function 
server <- function(input, output) {
  output$selected_value <- renderText({input$slider})
  output$selected_option <- renderText({input$dropdown})
  output$selected_date <- renderText({input$date})
  output$txtout <- renderText({
    paste(input$txt1, input$txt2,
          input$txt3, input$txt4, input$txt5,
          input$txt6, input$txt7, input$txt8,
          sep = " " )
  })
  output$plot <- renderPlot({
    ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
  })
}

 

<ui.R>


# Loading the libraries
library(shiny)
library(shinythemes)
library(ggplot2)

#UI Defined 
ui <- fluidPage(theme = shinytheme("superhero"),
                navbarPage(
                  
                  # mainPanel
                  "Welcome to INFO",
                  
                  # Tab 1
                  tabPanel("Tab 1",
                           mainPanel(
                             tags$h3("Register to INFO:"),
                             textInput("txt1", "Name:", ""),
                             textInput("txt2", "Surname:", ""),
                             textInput("txt3", "Email:", ""),
                             textInput("txt4", "Mobile.No:", ""),
                             textInput("txt5", "Education:", ""),
                             textInput("txt6", "College:", ""),
                             textInput("txt7", "Programming Language:", ""),
                             textInput("txt8", "Area of Interest:", ""),
                             
                             hr(),
                             h4("Here is your Details"),
                             verbatimTextOutput("txtout"),
                           )),
                  # TabPanel
                  tabPanel("Tab 2",
                           h3("Hello !! Here is the Plot Graph,
Slider, Dropdown and Date picker!!!"))),
                hr(),
                (
                  plotOutput("plot") #PlotGraph
                ),
                hr(),
                sidebarPanel(
                  sliderInput("slider", "Select a value:", min = 10,
                              max = 500, value = 125),
                  selectInput("dropdown", "Select an option:",
                              c("R", "JAVA", "C++")),
                  dateInput("datepicker", "Select a date:"),
                ),#SidebarPanel
                mainPanel(
                  h3("Selected values:"),
                  textOutput("selected_value"),
                  textOutput("selected_option"),
                  textOutput("selected_date"),
                )
)

 

 

Shiny Tutorial

 

Shiny Tutorial

This is a shiny tutorial.

bookdown.org

 

 

 

 

 

 

 

 

 

 

 

 

'언어 > R' 카테고리의 다른 글

ggplot2  (0) 2025.01.28
단축키  (0) 2025.01.12
load data  (0) 2024.07.19
R COPR repository  (0) 2024.06.12
basic  (0) 2024.02.17