Как я могу создать PDF (в определенном формате) из входных данных, взятых из моего блестящего приложения в R? - PullRequest
0 голосов
/ 16 марта 2020

Я создал блестящее приложение, которое позволяет вам вводить информацию о продукте, количестве и стоимости и выдает результат. Я бы хотел, чтобы пользователь загрузил его в pdf-файл, отформатированный по-другому.

Вот мой код

код пользовательского интерфейса


body <- dashboardBody(
        tabItem(
        tabName = 'Create_PI',
        inputPanel(
            selectizeInput(inputId = 'Customer_Name',label='Customer Name',
                           choices= sales$Customer, options = list(create=T)),
            textInput(inputId = 'Contact',label='Contact Person'),
            dateInput(inputId = 'Date', label = 'Date', format = 'dd MM yy')),
        inputPanel(
            selectizeInput(inputId = 'Product_Name1', label='Product Name',
                           choices= sales$Product, options = list(create=T)),
            numericInput(inputId = 'Quantity1',value=0,label = 'Quantity (kg)',
                         min = 1, width = '100px'),
            numericInput(inputId = 'Rate1',value=0,label = 'Rate (INR/kg)',
                         min = 1, width = '100px'),
            textOutput(outputId = 'total1')
        ),
        inputPanel(
            selectizeInput(inputId = 'Product_Name2', label='Product Name',
                           choices= sales$Product, options = list(create=T)),
            numericInput(inputId = 'Quantity2',value=0,label = 'Quantity (kg)',
                         min = 1, width = '100px'),
            numericInput(inputId = 'Rate2',value=0,label = 'Rate (INR/kg)',
                         min = 1, width = '100px'),
            textOutput(outputId = 'total2')
        ),
        inputPanel(
            numericInput(inputId = 'CGST', value = 9, label = 'CGST'),
            numericInput(inputId = 'SGST', value = 9, label = 'SGST'),
            textOutput(outputId = 'Final_Total'),
            downloadButton(outputId = 'Create',label='Create PI')
        )
)

код сервера

### The PI part
   server <- function(input, output) {
 output$total1 <- renderText(
        paste('INR',formatC(input$Quantity1*input$Rate1, format="d", big.mark=','))

    )
    output$total2 <- renderText(
        paste('INR',formatC(input$Quantity2*input$Rate2, format="d", big.mark=','))
    )
    output$Final_Total <- renderText({
        total1 <- input$Quantity1*input$Rate1
        total1[is.na(total1)] <-0
        total2<-input$Quantity2*input$Rate2
        total2[is.na(total2)]<-0
        gst <- (input$CGST+input$SGST)/100
        finaltotal <- total1+total2+(gst*(total1+total2))
        paste('Final Rate INR',formatC(finaltotal, format="d", big.mark=','))
    })
}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...