当前位置: 首页 > 知识库问答 >
问题:

如果其他语句在R闪亮的计算

韩阳云
2023-03-14

我已经开始练习R闪亮,请在下面的代码中找到我试图进行计算的部分。请协助获取输出,因为我无法生成。

用户界面

库(发光)库(发光板)

我的页面

titlePanel(“零基成本模型”),

侧边栏

侧边栏面板(“输入客户详细信息”),

条件="input.tabselect==1",

             textInput("client_name", "Enter the Client Name", value = " "),

             selectInput("route_IO", "Enter the route whether it is Inbound or Outound", 
             choices = c("Inbound","Outbound"), selected = NULL, multiple = FALSE),

             textInput("route_start", "Enter the route start point", value = ""),

             textInput("route_end", "Enter the route end point ", value = ""),

             radioButtons("GST_Mechanism", "Enter the mechanism of GST",
             choices = c("RCM","FCM"), selected = NULL ),style = {"color:green;font-size: 20px"}),


conditionalPanel(condition = "input.tabselect==2",

              textInput("model","Enter the Model of the Vehicle",value = " "),               

              numericInput("n","Enter the distance between start location and end location in KMs", value = 1, min = 1),


              selectInput("Road type", "Enter the Road or Terrain Type", 
              choices = c("Highway","Non-Highway","Hilly","Non Tar","Type B","Type C"),
              selected = NULL, multiple = FALSE),

              radioButtons("vehicle_type", "Enter the vehicle type", 
              choices = c("Market","Dedicated"), selected = NULL ),

              numericInput("fuel price","Enter the Fuel Price, Inr/Litre", value = 1, min = 1),

              numericInput("fuel eff with load","Enter the Fuel Price with load, Inr/Litre", value = 1, min = 1),     

              numericInput("fuel eff without load","Enter the Fuel Price with load, Inr/Litre", value = 1, min = 1),

              numericInput("trip efficiency","Enter the trip efficiency in percentage", 
              value = 1, min = 1, max = 100, step = 0.5),

              numericInput("run", "Enter run", 1),

              sliderInput("profir_margin", "Enter the profit margin for transporter", 
              min = 0, max = 30, step = 0.5, value = " ")),


conditionalPanel(condition = "input.tabselect == 3",

                 numericInput("driver","Enter the number of Drivers Involved for the trip",1),
                 numericInput("Driver_sal","Enter the salary of all the Drivers Involved for the trip",1),
                 numericInput("cleaner","Enter the number of Cleaners Involved for the trip",0),
                 numericInput("Cleaner_sal","Enter the salary of all the Cleaners Involved for the trip",0),
                 numericInput("Bhatta","Enter the daily bhatta for driver + cleaner as per 25 day working ",1),
                 numericInput("Admin","Number of  Admin Staff ",1),
                 numericInput("Admin_route","Number of Routes Handled by Admin Staff ",1),
                 numericInput("Admin_sal","Enter the salary of the Admin Staff",1),
                 numericInput("Admin_sal","Enter the salary of the Admin Staff",1),
                 numericInput("Tar","Enter the cost for Tarpaulin",1),
                 numericInput("Bank","Enter the bank Guarantee Amount (INR/Month): ",1),
                 numericInput("Gps","Enter the GPS installation Cost (One Time): ",0),
                 numericInput("Gps_trip","GPS Trip Charge ",0)),


conditionalPanel(condition = "input.tabselect == 4",

                 numericInput("Amc","Enter the AMC cost (Inclusive of GST) ",1),
                 numericInput("Ann_run","Enter annual running of the vehicle",1),
                 numericInput("warai","Enter the Loading/Unloading/Warai charges",1),
                 numericInput("Cleaner_sal","Enter the salary of all the Cleaners Involved for the trip",0),
                 numericInput("Toll","Enter the toll charge of the trip (One Side) ",1),
                 numericInput("LR","Enter the LR charges ",1),
                 numericInput("RTO","Enter the RTO Expense ",1),
                 numericInput("Gunda","Enter the Gunda Tax",1),
                 numericInput("Over_height","Enter the over height challan cost",1)),

conditionalPanel(condition=“input.tabselect==5”,

                 numericInput("front tyres","Enter the number of front tyres",2),
                 numericInput("rear tyres","Enter the number of rear tyres",4),
                 numericInput("tyre life","Enter the Life of tyre in Km",60000),
                 numericInput("front tyre cost","Enter the front tyre cost per unit",16000),
                 numericInput("rear tyre cost","Enter the rear tyre cost per unit",16000),
                 numericInput("LR","Enter the LR charges ",1),
                 numericInput("RTO","Enter the RTO Expense ",1),
                 numericInput("Gunda","Enter the Gunda Tax",1),
                 numericInput("Over_height","Enter the over height challan cost",1)),


conditionalPanel(condition = "input.tabselect == 6",

                 numericInput("License","Enter the one time License Cost",1000),
                 numericInput("Reg_char","Enter the one time registration charger",25000),
                 numericInput("Nat_permit","Enter the charges for national permit (INR/Yr)",20000),
                 numericInput("Road_tax","Enter the Road Tax amount (INR/Yr)",16000),
                 numericInput("Fitness_cert","Enter the charges for fitness certificate",2500),
                 numericInput("Puc","Enter the charges for PUC ",600),
                 numericInput("RTO","Enter the RTO Expense ",1),
                 helpText("Insurance Cost"),
                 numericInput("IDV","Enter the insured declaration value in percentage",90),
                 numericInput("Insurance_cost","insurance cost",3)),


conditionalPanel(condition = "input.tabselect == 7",


                 numericInput("Chasis","Enter the original cost of chasis and cabin",100000),

                 numericInput("Reg_char","Enter the number of years after chasis and cabin making",0))),

#submitButton(“提交前检查详细信息”)#

mainPanel(

          tabsetPanel(type = "pills",

                      tabPanel("Client & Route Details", value =1, 
                                textOutput("Myclient_name"), textOutput("Myroute_IO"), 
                               textOutput("Myroute_start"), textOutput("Myroute_end"),  textOutput("MyGST"), 
                               style = {"color:black;font-size: 20px;line-height: 2.92857143"}),

                      tabPanel("Trip Detail",value =2, textOutput("dist"),textOutput("Mymodel")),
                      tabPanel("Fixed Operating Cost",value =3),
                      tabPanel("Maintenance Cost",value =4),
                      tabPanel("Variable Cost",value =5),
                      tabPanel("Regulatory and Insurance Cost",value =6),
                      tabPanel("Body Chasis", value = 7, textOutput("MyChasis"), textOutput("MyReg_char1")),

                      id = "tabselect"

                      ))

)))

**Server**

库(发光)库(发光板)

shinyServer(功能(输入、输出){

         output$Myclient_name <- renderText({

           paste("Please Enter Client's Name:", input$client_name)

         })

        output$Myroute_IO <-  renderText({

          paste("Route Selected Is As : ", input$route_IO)

          })

        output$Myroute_start <-  renderText({

          paste("Start point of the client entered: ", input$route_start)

          })

        output$Myroute_end <-  renderText({

          paste("End point of the client entered: ", input$route_end)


          })

        output$Myvehicle_type <-  renderText({

          paste(" Vehicle used is Market or Dedicated: ",input$vehicle_type)


          })

        output$Myprofir_margin <- renderText({


          paste("Profit Margin for trip to be given to transporter: ",input$profir_margin)


          })

        output$MyGST <- renderText({


          paste("GST mechanism selected by the client is: ",input$GST_Mechanism)

                         })

        output$dist <- renderText({


         paste("The Distance Entered is : ", input$n)

        })


        output$Mymodel <- renderText({


          paste("The vehicle model Entered is : ", input$model)

        })


        output$MyChasis <- renderText({

          paste("Original Cost of the Chasis is :", input$Chasis)

        })


        output$MyReg_char1 <- renderText({

          if (as.numeric(input$Reg_char == 1)  ){

            paste("The current cost of the vehicle with respect to number of years: ", 
                  as.numeric(input$Chasis * 0.9500))

          } else{

            paste("Not in Condition")

          }


        })

共有1个答案

齐涛
2023-03-14

请参阅下面的工作模型。我建议你看看一些制作闪亮仪表板的教程(https://shiny.rstudio.com/reference/shiny/latest/fluidPage.html),因为你上面的代码在错误的地方有参数,你错过了真正调用仪表板的东西...

library(shiny)
library(shinydashboard)

ui <- fluidPage(

  titlePanel("Zero Based Costing Model"),

  sidebarLayout(

    sidebarPanel(
      "Enter client details",
      numericInput("Chasis","Enter the original cost of chasis and cabin",100000),
      numericInput("Reg_char","Enter the number of years after chasis and cabin making",0)
    ),
    mainPanel(
      tabsetPanel(type = "pills",
                  tabPanel("Body Chasis", value = 7, textOutput("MyChasis"), textOutput("MyReg_char")),
                  id = "tabselect"
      )
    )
  )
)

server <- function(input, output){


  output$MyChasis <- renderText({

    paste("Original Cost of the Chasis is :", input$Chasis)

  })


  output$MyReg_char <- renderText({

    if (as.numeric(input$Reg_char == 1)  ){

      paste("The current cost of the vehicle with respect to number of years: ", as.numeric(input$Chasis * 0.9500))

    } else{

      paste("Not in Condition")

    }


  })

}

shinyApp(ui, server)
 类似资料:
  • 所以读了一些书之后我看到了 不是使用可选选项的首选方式(http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html).但如果我有这样一个if语句: 这是最好的方法还是有更推荐的方法?

  • 有人有关于如何计算两个圆的相交面积的闪亮代码或R代码吗? 图书馆(闪亮) 我的页面 #申请标题标题板(“选择你的可能性”), #侧边栏与滑块输入箱的数量侧边栏布局(侧边栏面板( ))) 库(闪亮)库(plotrix)库(栅格) shinyServer(功能(输入、输出){ 输出$distPlot }) })

  • 问题内容: 我注意到以下代码在Python中是合法的。我的问题是为什么?是否有特定原因? 问题答案: else仅当你的while条件为假时才执行该子句。如果你break超出循环范围,或者引发了异常,则不会执行该异常。 考虑它的一种方法是关于条件的构造: 一个示例可能类似于:

  • 我想知道在ReactJSJSX中是否可以嵌套if else if? 我尝试过各种不同的方法,但我无法让它发挥作用。 我正在寻找 我已经试过了,但是我不能把它渲染出来。我试过各种方法。添加嵌套if后,它总是会中断。 使现代化 最后,我选择了将其移动到renderContent并调用该函数的解决方案。不过,这两个答案都有效。我想我可以使用内联解决方案,如果它用于简单的渲染和更复杂的情况下的渲染内容。

  • 我让用户在一个< code>int[]中输入5个int的列表。然后,我用一个简单的< code>for语句遍历int[]中的这些int。我声明了一个名为“evens”的< code>int变量如果int[]中的数字at ,< code > evens ; 现在我有了 语句: 问题是,无论偶数的值是多少,都会调用它。它可以是5或3,但仍会被调用。我最近一直在使用C#,但这是简单的Java。 整机代码

  • 我发现了如何在Shiny中更改用户界面的背景色。我发现的问题是,它还为我用显示的表的背景上色。这里我展示一个虚拟示例。 用户界面。R shinyUI(页面带有侧栏( 标题面板(“虚拟”), 侧栏面板(标签$hr()), 主面板( 服务器R ShinyServer(函数(输入,输出){输出$虚拟 我得到的是这个 我想得到的(我用GIMP重新创建了它)是 谢谢大家的帮助!