I work with the "pander" and "sendmailr" packages to send a small data frame in the body of the message, and not as an attachment. I would like to send it to my gmail account as well.
Iβm close, but the column headers will not align with the columns themselves in the body of the message in the same way as in Rstudio, for example, basically the column headers are too wide to align the data columns below them.
The problem seems to be that dashes and spaces are compressed in different mail clients (I tried this in gmail, yahoo and hotmail over the Internet and through the mail client that comes with OS X Mavericks). I was able to fix this problem in my OS X mail client by going to "settings" and checking the "Use fixed-width font for text messages" checkbox, but I would like it to work on multiple devices, multiple clients, etc. for many of my colleagues, so I wonder if there is a way that is not related to global email settings.
Here is the code to reproduce the problem:
library(sendmailR) # for emails from R library(pander) # for table-formatting that does not require HTML results <- head(iris) pander(results) # widths look great so far... a = pandoc.table.return(results) strsplit(a, "\n") # widths still look great... panderOptions('table.split.table', Inf) # show all columns on same line msg_content <- mime_part( pandoc.table.return(results, style = "multiline") ) # I'm using my own gmail address for email_from and email_to sendmail(from = email_from, to = email_to, subject = "test", msg = msg_content )
... and the received message has the problem described above.
Next, you can see an image that illustrates the problem:

source share