R Club

Documentation for The Random Heart Generator

posted by: Mike Covington

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()

plot of chunk default_hearts

By changing n, you can plot any number of hearts:

hearts(n = 10)

plot of chunk ten_hearts

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)

plot of chunk lots_of_hearts

Since love can be messy, you can make your plot a bit more chaotic by changing the up option:

hearts(up = FALSE)

plot of chunk up+down_hearts

comments powered by Disqus