# You R my Valentine!

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**Johannes B. Gruber on Johannes B. Gruber**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today is Valentine’s Day. And since both I and my sweetheart are `R`

enthusiasts, here is how to say “I love you” using a statistical programming language:

library("dplyr") library("gganimate") library("ggplot2") hrt_dat <- data.frame(t = seq(0, 2 * pi, by = 0.01)) %>% bind_rows(data.frame(t = rep(max(.$t), 300))) %>% mutate(xhrt = 16 * sin(t) ^ 3, yhrt = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t), frame = seq_along(t)) %>% mutate(text = ifelse(frame > 300, " J", "")) %>% mutate(text = ifelse(frame > 500, "A J", text)) %>% mutate(text = ifelse(frame > 628, "A + J", text)) %>% mutate(texty = 0, textx = 0) ggplot(hrt_dat, aes(x = xhrt, y = yhrt)) + geom_line(colour = "#C8152B") + geom_polygon(fill = "#C8152B") + geom_text(aes(x = textx, y = texty, label = text), size = 18, colour = "white", vjust = "center") + theme_void() + transition_reveal(frame)

To

**leave a comment**for the author, please follow the link and comment on their blog:**Johannes B. Gruber on Johannes B. Gruber**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.