Monday, December 13, 2021

R Programming examples

# import shiny package

library(shiny)


# define fluid page layout

ui <- fluidPage(

  textInput(inputId = "num", label = "Choose a number",

            value = "", width = 100, placeholder = NULL),

  plotOutput("hist"),

  verbatimTextOutput("stats")

)

server <- function(input, output)

{

  # use reactive to create

  # a reactive expression

  data <- reactive({rnorm(input$num)})

  

  output$hist <- renderPlot({hist(data())})

  output$stats <- renderPrint({summary(data())})

}


# create shiny app object

# using shinyApp

shinyApp(ui = ui, server = server)


----------------------------****************-----------------------------


x <- seq(-pi, pi, 0.1)

plot(x, cos(x))


--------------------**************-------------------------------


v <- LETTERS[1:4]

for ( i in v) {

   print(i)

}

No comments:

Post a Comment