The monetizr package: make money on your open source R packages

[This article was first published on Variance Explained, 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.

I’ve had the great privilege to be a small part of the R open source community, contributing packages like broom, gganimate, fuzzyjoin, and ggfreehand. In the process I’ve become friends and colleagues with brilliant statisticians and data scientists and learned to engage with data in powerful ways.

But there’s one thing that my colleagues and I haven’t gotten from R open source involvement: money. Until now.

Introducing the monetizr package

To this end, I am introducing the monetizr package, which lets you monetize a package through advertisements.

Suppose you’ve created a function:

multiply_by_two <- function(x) {
  x * 2
}

This function takes its input and multiplies it by two. By enterprise software standards this is quite useful.

You’ve shared your function and people are using it:

multiply_by_two(10)
## [1] 20

But every time they use it, you are not capturing the value- you are in fact getting nothing from it. What a ripoff!

Marketably

The monetize package provides the marketably function, which modifies a function to display an advertisement. (Why “marketably”? Because functions that return other functions should be adverbs). You can provide ads for paying third parties, or you can advertise your own work. Here I’ll add an advertisement for my blog:

library(monetizr)

ad <- "Check out my blog, Variance Explained, at www.varianceexplained.org!"
multiply_by_two_enterprise <- marketably(multiply_by_two, ad)

Now, when anyone calls it:

multiply_by_two_enterprise(10)
## Check out my blog, Variance Explained, at www.varianceexplained.org!
## [1] 20

You’ve captured some value!

Also try the html = TRUE argument. Now thanks to htmltools, this will pop up in the user’s browser or RStudio “Viewer” window, where it is even harder for your customers to ignore.

ad <- paste("Check out my blog, ",
            "<a href='www.varianceexplained.org!'>Variance Explained</a>")
multiply_by_two_enterprise <- marketably(multiply_by_two, ad, html = TRUE)

multiply_by_two_enterprise(20)

You can also insert a delay (in seconds) after the ad is shown with pause, much like YouTube’s ads:

ad <- "Check out my blog, Variance Explained!"
multiply_by_two_enterprise <- marketably(multiply_by_two, ad, pause = 5)

multiply_by_two_enterprise(20)

Monetize an entire package

Usually you’ll want to monetize your entire package, not just a single function. So monetizr provides a way to make this convenient- market_all:

market_all(ad = "Have I mentioned my blog, Variance Explained?")

Place this in the zzz.R file of your package to add advertising to all your functions. (See here for more on zzz.R).

By next week all of my packages on GitHub and CRAN will be monetized in this way, and I’m counting on others in the community to follow.

Impression Analytics

Ever since I entered industry I appreciate the importance of analytics: understanding how many impressions you are receiving, not just the number of clicks. Here those impressions are represented by the number of times each of your monetized functions is used.

The monetizr package supports this core business need. Simply define a route on your own website or back-end server to record an impression, and then your function will fire off a request to that site on each call:

url <- "http://example.com/impressions/record"
ad <- "Check out my blog, Variance Explained, at www.varianceexplained.org!"
multiply_by_two_enterprise <- marketably(multiply_by_two, ad,
                                         impression_url = url)

This will send a GET request (with the response discarded) to

http://example.com/impressions/record?function=multiply_by_two&id=1

(Where id is the index of the ad that was shown, among the choices given as ad).

Upcoming Features

Functions that are currently in development for monetizr include:

  • expensively: Have a function require a bitcoin payment with each call
  • temporarily: Have a function offer a “free trial” for a number of uses or time period before requiring payment
  • premiumly: Have a function require payment to activate particular options.

If you have other suggestions, please open a GitHub Issue, or better yet hop on a call with one of our sales staff!

To leave a comment for the author, please follow the link and comment on their blog: Variance Explained.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)