我使用下面的代码与我的朋友分享数据框“my_data1”,代码工作正常。但是我想要分享另一个数据框“my_data2”。请在我的代码中建议在何处以及如何添加第二个表
library(sendmailR)
library(pander)
from <- "<me@gmail.com>"
to <- "<friend@gmail.com>"
subject <- "Important Report of the Day!!"
body <- "This is the result of the test:"
mailControl=list(smtpServer="ASPMX.L.GOOGLE.COM")
#-----------------------------------------------------
#-----------------------------------------------------
msg_content <- mime_part(paste('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body><pre>', paste(pander_return(pander(my_data1, style="multiline", caption = "Net Bookings")), collapse = '\n'), '</pre></body>
</html>'))
msg_content[["headers"]][["Content-Type"]] <- "text/html"
sendmail(from=from,to=to,subject=subject,msg=msg_content,control=mailControl)
答案 0 :(得分:3)
在<p><pre>', paste(pander_return(pander(my_data2, style="multiline", caption = "New Caption")), collapse = '\n'), '</pre>
和</pre>
之间添加</body>
可以为您提供所需的结果。
如果要在两个表之间插入一些文本,可以执行以下操作:
<p>the text you want to insert between the tables</p>
<pre>', paste(pander_return(pander(my_data2, style="multiline", caption = "New Caption")), collapse = '\n'), '</pre>