The Random Heart Generator
I made The Random Heart Generator for Valentine’s Day as part of a weekly class I help teach on R and ggplot.
Defaults
The default parameters of The Random Heart Generator are:
hearts(n = 5, up = TRUE, free.love = FALSE)
Usage
The Random Heart Generator plots five hearts of random size, position, and color (from the rainbow color palette):
source("random_heart_generator.R")
hearts()
By changing n
, you can plot any number of hearts:
hearts(n = 10)
However, if you try to plot too many (100+), you will get a warning to help prevent R from becoming non-responsive:
hearts(n = 150)
## [1] "That's way too many hearts for you to handle."
This safeguard can be bypassed with the free.love
option:
hearts(n = 150, free.love = TRUE)
Since love can be messy, you can make your plot a bit more chaotic by changing the up
option:
hearts(up = FALSE)