Good Day, making application in RStudio/Shiny is very new to me and I am working with a project in which an external file is to be used as the input data. Here is my CSV:
my supposed to be app:
So the user insert a csv with appliance name in row 1 and their wattage in row 2 just like in the picture above, then the selectInput will be updated. The user choose what appliance and hours of usage then it will be calculated for its cost
Here is my server code:
server <- function(input,output,session) {
observeEvent(input$file1, {
mytable <- read.csv(input$file1$datapath)
updateSelectInput(session, "select", "Appliances",
choices = colnames(mytable))
})
dataset_day <- reactive ({
costday <- ((input$select * input$hour) / 1000) * 8.9535
costday <- data.frame(costday)
names(costday) <- "Electricity Cost per day (Philippine Peso)"
print(costday)
})
dataset_month <- reactive ({
costmonth <- (((input$select * input$hour) / 1000) * 8.9535) * 30
costmonth <- data.frame(costmonth)
names(costmonth) <- "Electricity Cost per month (Philippine Peso)"
print(costmonth)
})
I need help in putting the value written in the CSV of the chosen appliance by the user to the equation.
In short how to fix the non-numeric argument to binary operator error.
I think the error is in the input$select but I am lost about this.
((input$select * input$hour) / 1000) * 8.9535
Do I need to change or add something in order to fix this? Is this app possible to do? Thank you in advance!