Happy Valentines day by Nerds

[This article was first published on Rbloggers – The Analytics Lab, 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.

Real nerds on Valentines day graph hearts instead of drawing them. My drawing skills are not what I like them to be, my R skills are though! Therefore, let’s draw a heart in R instead on paper!

heart curve

dat<- data.frame(t=seq(0, 2*pi, by=0.01) ) xhrt<- function(t) 16*sin(t)^3 yhrt<- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t) dat$y=yhrt(dat$t) dat$x=xhrt(dat$t) with(dat, plot(x,y, type="l", axes=FALSE, frame.plot=FALSE, labels = FALSE, xlab = '', ylab = '')) with(dat, polygon(x,y, col="#FF7575"))

Inspired by: http://mathworld.wolfram.com/HeartCurve.html

 

To leave a comment for the author, please follow the link and comment on their blog: Rbloggers – The Analytics Lab.

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.