admin管理员组文章数量:1399466
I've built an Rmarkdown document which includes some ggplot visualizations as well as some buttons to download the data supporting the visualizations. These buttons were built using the download_this package.
I've rendered the Rmd to html and have then used compose_email to generate the content for the email.
When I view the email object (blastula_message email_message) everything looks great in the Viewer window in Rstudio, the buttons work, I can download the data as well as the images in jpeg format.
When I then use smtp_send, using the correct email server details the email sends however when it lands into my inbox the buttons are stripped out, only the text for the buttons remains
Any suggestions for why this may be happening would be greatly appreciated
---
title: "Analysis of the mtcars Dataset"
author: "Your Name"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Introduction
The mtcars dataset is a built-in dataset in R that contains data about different car models. It includes 32 observations with 11 variables, such as miles per gallon (mpg), horsepower (hp), weight (wt), and more.
In this report, we will:
Summarize the dataset
Calculate some basic statistics
Visualize relationships between key variables
Dataset Overview
# Display the first few rows of the dataset
```{r}
head(mtcars)
```
Summary Statistics
Here, we calculate summary statistics for the numerical variables in the dataset.
# Summary statistics
```{r}
summary(mtcars)
```
Visualization
Well create a scatter plot to explore the relationship between weight (wt) and miles per gallon (mpg).
```{r}
library(ggplot2)
```
# Scatter plot of weight vs. mpg
```{r}
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point(color = "blue", size = 3) +
labs(title = "Scatter Plot of Weight vs. Miles Per Gallon",
x = "Weight (1000 lbs)",
y = "Miles Per Gallon (mpg)") +
theme_minimal()
```
```{r}
# Save mtcars dataset as an Excel file
temp <- mtcars
# Add a download button using downloadthis
downloadthis::download_this(
.data = temp,
output_name = "mtcars_dataset",
output_extension = ".xlsx",
button_label = "Download mtcars Dataset as Excel File",
button_type = "success"
)
```
Conclusion
This report provides a basic overview of the mtcars dataset. We observed some interesting relationships, such as the negative correlation between weight and miles per gallon. Further analysis could include more advanced statistical modeling or exploring other variables in the dataset.
```
Here is my code to send the email
# LOAD THE LIBRARY
library(blastula)
# RENDER THE HTML DOCUMENT FROM Rmarkdown
rmarkdown::render("C:/myEmail.Rmd", output_format = "html_document", output_file = "mtcars_file.html")
# READ THE HTML FILE CONTENT
mtcars_html_content <- paste(readLines("mtcars_file.html"), collapse = "\n")
# COMPOSE THE EMAIL
mtcars_email <- compose_email(
body = md(mtcars_html_content),
content_width = "1800px"
)
mtcars_email
# SEND THE EMAIL
mtcars_email %>%
smtp_send(
from = "[email protected]",
to = "[email protected]",
subject = paste0("MTCARS - ", Sys.Date()),
credentials = creds_key("outlook")
)
本文标签: rIssues with sending blastula emails with buttons in the email contentStack Overflow
版权声明:本文标题:r - Issues with sending blastula emails with buttons in the email content - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744136648a2592428.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论