Here is an example of what I would like to do.
This was edited from an example from Abhinav Agrawal on GitHunGist:
An example .csv would look like this code:
df = data.frame(matrix(c(80, 60, 50, 40, 50, 55), nrow=3, ncol=2))
colnames(df) <- c("ht_inches", "wt_lbs")
library(shiny)
ui <- fluidPage(
titlePanel("File Input"),
sidebarLayout(
sidebarPanel(
fileInput("file","Upload the file"),
tags$hr(),
checkboxInput(inputId = 'header', label = 'Header', value = TRUE),
checkboxInput(inputId = "stringAsFactors", "stringAsFactors", FALSE)
),
mainPanel(
uiOutput("tb")
)
)
)
server <- function(input,output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.table(file=file1$datapath, sep=",", header = input$header, stringsAsFactors = input$stringAsFactors)
})
output$filedf <- renderTable({
if(is.null(data())){return ()}
input$file
})
output$sum <- renderTable({
if(is.null(data())){return ()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return ()}
data()
})
output$tb <- renderUI({
tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
}
shinyApp(ui, server)
What I would like to do is read in the table and create variables based on the csv called height and weight. Then create an output of BMI = weight/(height^2)
Thank you for the help!