3

Please find below my code that I am using to share my analysis (dataframe) with my friend in R. I am using sendmailR package and pander:

library(sendmailR)

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(vvv, style="multiline")), collapse = '\n'), '</pre></body>
</html>'))

msg_content[["headers"]][["Content-Type"]] <- "text/html"

sendmail(from=from,to=to,subject=subject,msg=msg_content,control=mailControl)

Problem is that in the mail the table is broken into two parts (8 column table and 4 column table) PFB the sample picture

enter image description here

How do I change my code so that my table of 12 columns remain intact.

After adding this line

panderOptions('table.split.table', Inf)

This is the email that I am getting enter image description here

AkshitR
  • 33
  • 3

1 Answers1

1

You have to increase or disable the default max width of the resulting markdown table via the split.tables argument of pandoc.table (that can be also used with the pander call, which will pass that argument to pandoc.table after all) or update the global options via panderOptions.

Quick example on updating your pander call:

paste(pander_return(pander(vvv, split.tables = Inf)), collapse = '\n')

Or set that globally for all future pander calls:

panderOptions('table.split.table', Inf)
daroczig
  • 28,004
  • 7
  • 90
  • 124
  • Thanks for replying. I got the table intact but it got screwed. Multiple columns are getting merged. How can I get them fit by altering their size and column auto fit. – AkshitR Mar 16 '16 at 08:21
  • @AkshitR that's why we have a sane default not to print tables with more than 80 characters just like on the good old VT100 terminals :) But besides joking, that will depend on how your browser/e-mail client renders the wide `
    ` tag. I think you want to add a HTML table to that e-mail instead of a verbatim markdown table -- look at eg `xtable` to generate HTML instead of markdown with `pander` (and I'm suggesting that despite the fact that I'm well committed to the latter package).
    – daroczig Mar 16 '16 at 08:25