marketably: Monetize a function by displaying an ad before the function...

Description Usage Arguments Details Examples

Description

Monetize a function by displaying an ad before it runs, optionally with a pause. Can also display HTML, which will appear either in the RStudio "Viewer" window or (if the viewer window is not available) in the.

Usage

1
marketably(func, ads, html = FALSE, pause = NULL, impression_url = NULL)

Arguments

func

Function to add advertising to

ads

A character vector from which to pick a random ad

html

Whether the ad should be rendered as HTML

pause

In seconds, an amount to wait after showing the ad before running the function.

impression_url

A URL to send a GET request to every time a function is called.

Details

If an impression_url is given, a GET request is sent along with the parameters function, with the function name, and adId, with the index of the ad that was selected.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
mean(1:10)

ad_mean <- marketably(mean, "Check out my blog, Variance Explained!")

ad_mean(1:10)

# We can insert a pause first
ad_mean <- marketably(mean, "Check out my blog, Variance Explained!",
                    pause = 3)
ad_mean(1:10)

# or we can include HTML
ad <- paste0("Check out my blog, <a href = 'http://varianceexplained.org'>",
             "Variance Explained</a>!")

ad_mean <- marketably(mean, ad, html = TRUE)
ad_mean(1:10)

dgrtwo/monetizr documentation built on May 15, 2019, 7:27 a.m.