简体   繁体   English

R Shiny app - 用户根据方程输入值和输出

[英]R Shiny app - users input values and output based on equation

I want to create a simple app whereby users input two values (pH and Temperature) and an output is generated based on the equation - Log₁₀(Activity)=3.202651+2.34307(ph)+0.061192(Temp)-1.008796(ph * Temp)-0.789125(ph²)-0.001125(Temp²)+1.000252(ph * Temp²)+1.2(ph³).我想创建一个简单的应用程序,用户输入两个值(pH 和温度)并根据等式生成输出 - Log₁₀(Activity)=3.202651+2.34307(ph)+0.061192(Temp)-1.008796(ph * Temp) -0.789125(ph²)-0.001125(Temp²)+1.000252(ph * Temp²)+1.2(ph³)。

Would anyone know the best way to do this?有人知道最好的方法吗?

Try this app.试试这个应用程序。 Check carefully the equation parameters in server function because thats not my strong side.仔细检查服务器函数中的方程参数,因为那不是我的强项。

library(shiny)

ui <- fluidPage(


    titlePanel("Equation Name"),


    sidebarLayout(
        sidebarPanel(
            numericInput(
                inputId = "t",
                label = "Temperature value",
                value = 1,
                min = NA,
                max = NA,
                step = NA,
                width = NULL
            ),
            numericInput(
                inputId = "ph",
                label = "ph value ",
                value = 1,
                min = NA,
                max = NA,
                step = NA,
                width = NULL
            ),
        ),

        mainPanel(h1("Result"),
           textOutput("result")
        )
    )
)


server <- function(input, output) {
    
    output$result <- renderText({
        as.character(
            log10(3.202651+ 
                      (input$ph * 43307) +
                      (0.061192*input$t) - 
                      (1.008796 * input$ph * input$t) - 
                      (0.789125*(input$ph**2)) -
                      (0.001125 *(input$t**2)) +
                      (1.0002352 *(input$ph * (input$t**2)))+
                      (1.2*(input$ph**3)))
        )
    })
    
 
    
}

# Run the application 
shinyApp(ui = ui, server = server)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM