Just Follow the code. The program is based on Developing Data products course on Coursera. I have added more comments and examples to enhance understanding.
ui.R |
# A shiny code requires two files: ui.R and server.R # This code will be saved as ui.R library(shiny) # call the Library to load into R shinyUI(pageWithSidebar( headerPanel(“Example inputs using Shiny”), sidebarPanel( #keyword numericInput for numbers numericInput(‘id1’, ‘#Description of Numeric input, labeled id1’, 0, min = 0, max = 10, step = 1), #numericInput(inputId, label, value, min = NA, max = NA, step = NA) #ckeckboxGroupInput for checkbox #checkboxGroupInput(inputId, label, choices, selected = NULL, inline = FALSE) |
server.R |
# A shiny code requires two files: ui.R and server.R # This code will be saved as server.R library(shiny) # call the Library to load into R shinyServer( function(input, output) { } ) |
Create a numeric input control
Description
Create an input control for entry of numeric values
Usage
numericInput(inputId, label, value, min = NA, max = NA, step = NA)
Arguments
inputId
Input variable to assign the control’s value to
label
Display label for the control
value
Initial value
min
Minimum allowed value
max
Maximum allowed value
step
Interval to use when stepping between min and max
Value
A numeric input control that can be added to a UI definition.
Checkbox Group Input Control
Description
Create a group of checkboxes that can be used to toggle multiple choices independently. The server will receive the input as a character vector of the selected values.
Usage
checkboxGroupInput(inputId, label, choices, selected = NULL, inline = FALSE)
Arguments
inputId
Input variable to assign the control’s value to.
label
Display label for the control, or NULL.
choices
List of values to show checkboxes for. If elements of the list are named then that name rather than the value is displayed to the user.
selected
The values that should be initially selected, if any.
inline
If TRUE, render the choices inline (i.e. horizontally)
Value
A list of HTML elements that can be added to a UI definition.
Create date input
Description
Creates a text input which, when clicked on, brings up a calendar that the user can click on to select dates.
Usage
dateInput(inputId, label, value = NULL, min = NULL, max = NULL,
format = “yyyy-mm-dd”, startview = “month”, weekstart = 0,
language = “en”)
Arguments
inputId
Input variable to assign the control’s value to.
label
Display label for the control, or NULL.
value
The starting date. Either a Date object, or a string in yyyy-mm-dd format. If NULL (the default), will use the current date in the client’s time zone.
min
The minimum allowed date. Either a Date object, or a string in yyyy-mm-dd format.
max
The maximum allowed date. Either a Date object, or a string in yyyy-mm-dd format.
format
The format of the date to display in the browser. Defaults to “yyyy-mm-dd”.
startview
The date range shown when the input object is first clicked. Can be “month” (the default), “year”, or “decade”.
weekstart
Which day is the start of the week. Should be an integer from 0 (Sunday) to 6 (Saturday).
language
The language used for month and day names. Default is “en”. Other valid values include “bg”, “ca”, “cs”, “da”, “de”, “el”, “es”, “fi”, “fr”, “he”, “hr”, “hu”, “id”, “is”, “it”, “ja”, “kr”, “lt”, “lv”, “ms”, “nb”, “nl”, “pl”, “pt”, “pt-BR”, “ro”, “rs”, “rs-latin”, “ru”, “sk”, “sl”, “sv”, “sw”, “th”, “tr”, “uk”, “zh-CN”, and “zh-TW”.