Rshiny 中的电子邮件问题 ::将数据框附加为 pdf/.html 来自 Shinyapps.io
EMailing Issue in Rshiny ::Attaching a Data Frame as pdf/.html from Shinyapps.io
[![i=iris
library(shiny)
library(mailR)
ui =fluidPage(
fluidRow(
div(id = "login",
wellPanel(title = "Mail your report",
textInput("to", label = "To:", placeholder = "To:"),
textInput("sub","Subject:"),
textInput("msg","Message:"),
actionButton("mailButton",label = "Send mail")
)
),tableOutput(outputId = "fo")
)
)
server = function(input, output, session) {
observeEvent(input$mailButton,{
isolate({
send.mail(from = "*****@gmail.com",
to = unlist(strsplit(input$to, ";", fixed = TRUE)),
subject = input$sub,
body = input$msg,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "******", ssl = TRUE),
authenticate = TRUE,
attach.files = "fo",html = TRUE,
send = TRUE)
})
})
output$fo <- renderTable({
a<- as.data.frame(iris)
a$new <- a$Sepal.Length+a$Sepal.Width
a
})
}
runApp(list(ui=ui,server=server)) ][1]][1]
在这里我们可以看到,在服务器函数中我计算了一个新列 a$new 并且整个数据框被保存回一个对象所以我需要将这个数据框作为 pdf/csv/ 邮寄。html 任何可能的格式请对此进行指导
i=iris
library(shiny)
library(mailR)
a<- as.data.frame(iris)
write.csv(a,file="test.csv")
ui =fluidPage(
fluidRow(
div(id = "login",
wellPanel(title = "Mail your report",
textInput("to", label = "To:", placeholder = "To:"),
textInput("sub","Subject:"),
textInput("msg","Message:"),
actionButton("mailButton",label = "Send mail")
)
),tableOutput(outputId = "fo")
)
)
server = function(input, output, session) {
observeEvent(input$mailButton,{
isolate({
send.mail(from = "****@gmail.com",
to = unlist(strsplit(input$to, ";", fixed = TRUE)),
subject = input$sub,
body = input$msg,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "nbwishes", ssl = TRUE),
authenticate = TRUE,
attach.files = "test1.csv",html = TRUE,
send = TRUE)
})
})
output$fo <- renderTable({
a<- as.data.frame(iris)
a$new <- a$Sepal.Length+a$Sepal.Width
write.csv(a,file="test1.csv")
})
}
runApp(list(ui=ui,server=server))
[![i=iris
library(shiny)
library(mailR)
ui =fluidPage(
fluidRow(
div(id = "login",
wellPanel(title = "Mail your report",
textInput("to", label = "To:", placeholder = "To:"),
textInput("sub","Subject:"),
textInput("msg","Message:"),
actionButton("mailButton",label = "Send mail")
)
),tableOutput(outputId = "fo")
)
)
server = function(input, output, session) {
observeEvent(input$mailButton,{
isolate({
send.mail(from = "*****@gmail.com",
to = unlist(strsplit(input$to, ";", fixed = TRUE)),
subject = input$sub,
body = input$msg,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "******", ssl = TRUE),
authenticate = TRUE,
attach.files = "fo",html = TRUE,
send = TRUE)
})
})
output$fo <- renderTable({
a<- as.data.frame(iris)
a$new <- a$Sepal.Length+a$Sepal.Width
a
})
}
runApp(list(ui=ui,server=server)) ][1]][1]
在这里我们可以看到,在服务器函数中我计算了一个新列 a$new 并且整个数据框被保存回一个对象所以我需要将这个数据框作为 pdf/csv/ 邮寄。html 任何可能的格式请对此进行指导
i=iris
library(shiny)
library(mailR)
a<- as.data.frame(iris)
write.csv(a,file="test.csv")
ui =fluidPage(
fluidRow(
div(id = "login",
wellPanel(title = "Mail your report",
textInput("to", label = "To:", placeholder = "To:"),
textInput("sub","Subject:"),
textInput("msg","Message:"),
actionButton("mailButton",label = "Send mail")
)
),tableOutput(outputId = "fo")
)
)
server = function(input, output, session) {
observeEvent(input$mailButton,{
isolate({
send.mail(from = "****@gmail.com",
to = unlist(strsplit(input$to, ";", fixed = TRUE)),
subject = input$sub,
body = input$msg,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "****@gmail.com", passwd = "nbwishes", ssl = TRUE),
authenticate = TRUE,
attach.files = "test1.csv",html = TRUE,
send = TRUE)
})
})
output$fo <- renderTable({
a<- as.data.frame(iris)
a$new <- a$Sepal.Length+a$Sepal.Width
write.csv(a,file="test1.csv")
})
}
runApp(list(ui=ui,server=server))