[This article was first published on R – TomazTsql, 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.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Gimmick not a poem, useless R code for your Valentine.
Code for this heart shaped useless poem:
library(tidyverse) ValentinePoem <- function(){ df<- data_frame(sq = seq(-30, 0, 0.005), x1 = (sin(sq)*sin(sq)), x2 = x1*-1, y = sqrt(cos(sq))*cos(200*sq) + sqrt(abs(sq)) - 0.7*(4 - sq^2)^0.01 ) %>% gather(heart, x,x1,x2) p <- ggplot(df, aes(x, y)) + geom_polygon(fill = "Red") + theme_void() + geom_text(size=6,aes(x=0, y=0, label="Errors are red, \n Reserved words are blue, \n I am here writing this useless\n R heart function for you!"), col="black") + theme(legend.position = "none") return(p) }
And once you have the function persistent in your environment, just run:
# Run function ValentinePoem()
And for the poets, here the R version of the poem:
Errors are red,
Reserved words are blue,
I am here writing this useless
R heart function for you!
Happy R-coding and happy Valentine’s day!
As always, code is available in at the Github in same Useless_R_function repository.
To leave a comment for the author, please follow the link and comment on their blog: R – TomazTsql.
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.