
tl;dr
The {monetize} R package gives you inspiration for monetising your R package. Developers rise up!
Free as in free
Thereβs one good reason why SAS, SPSS and Stata1 are such successful and beloved statistical tools: money.
For some reason, R remains free and open source. But what if Ihaka & Gentleman originally wanted users to be charged a literal (New Zealand) dollar2 every time they use the $ symbol to access an element from an object? Iβm just asking the question!
Us package developers should seize the initiative and harvest the sweet, sweet bounty of our labour. But how? I will tell you the secret!
Free as in not quite
Introducing the {monetize} R package! It will provide the inspiration you seek. Serious entrepreneurs can install from GitHub3.
install.packages("remotes") # if not yet installed
remotes::install_github("matt-dray/monetize")
library(monetize)
Welcome to the monetize(TM) package FREE TRIAL version!
Try our EXCLUSIVE add_one() function!
Try watch_ad() to gain MEGA COINS and increase your MEMBER LEVEL for REWARDS!
And now a quick message from our sponsor:
π§ IMBIBE ACME(TM)-BRAND FRUIT PULP (7% FEWER INSECT COMPONENTS)! πͺ³
The package contains the exclusive add_one() function, which surprisingly doesnβt come pre-installed with base R. A gap in the market!
Users should speculate to accumulate, so thereβs a small cost to use the function. In {monetize}, each use of a function costs 1 MEGA COIN.
Because I am so kind, I have chosen for users to receive a 30-day FREE TRIAL of the package and to receive 3 MEGA COINS as an exclusive NEW-MEMBER PERK.
One use of the function costs the low, low price of 1 MEGA COIN. Merely a small payment, or βmicro transactionβ, if you will.
add_one(1)
π
You have 30 days left of your FREE TRIAL!
π
Your MEMBER LEVEL is 1! Try watch_ad()!
π° Your MEGA COIN balance is now 2! Try watch_ad()!
[1] 2
Along with the result, the function helpfully prints the number of days left in your FREE TRIAL, your MEMBER LEVEL and the number of MEGA COINS you have left.
Whatβs a MEMBER LEVEL? Well, at MEMBER LEVEL 1, the function canβt guarantee a correct result. 20% of the time thereβll be an off-by-one error. But R users index from 1 anyway, so theyβll be used to that.
add_one(1)
π
You have 30 days left of your FREE TRIAL!
π
Your MEMBER LEVEL is 1! Try watch_ad()!
π° Your MEGA COIN balance is now 1! Try watch_ad()!
[1] 3
How can you get the correct result 100% of the time? Thatβs an exclusive for MEMBER LEVEL 2. How do you reach MEMBER LEVEL 2? What happens if you run out of MEGA COINS?
add_one(1)
π
You have 30 days left of your FREE TRIAL!
π
Your MEMBER LEVEL is 1! Try watch_ad()!
Error: π You'll need more MEGA COINS to re-use this function! Try watch_ad()!
Answer: simply watch some ads! Iβve managed to get an ad deal with the famous Acme(TM) Corporation. Maybe you could get a sponsorship deal from a third-party whose interests align with your usersβ interests; maybe SAS, SPSS or Stata would be interested?
Anyway, the user can just watch_ad() in exchange for MEGA COINS: Iβve allowed the user to employ their FREE WILL to watch a "short" ad for 1 MEGA COIN or a "long" ad for 3 MEGA COINS.
watch_ad("short")
π CONSUME ACME(TM)-BRAND RECONSTITUTED MEAT-LIKE CYLINDERS! π
π CONSUME ACME(TM)-BRAND RECONSTITUTED MEAT-LIKE CYLINDERS! π
π CONSUME ACME(TM)-BRAND RECONSTITUTED MEAT-LIKE CYLINDERS! π
π CONSUME ACME(TM)-BRAND RECONSTITUTED MEAT-LIKE CYLINDERS! π
π CONSUME ACME(TM)-BRAND RECONSTITUTED MEAT-LIKE CYLINDERS! π
Congratulations! Your new MEGA COIN total is 1!
Reach MEMBER LEVEL 2 after gaining 10 all-time MEGA COINS and MEMBER LEVEL 3 after 20 MEGA COINS.
Whatβs the exclusive MEMBER LEVEL 3? Well, you get the perk of an actually-correct answer like in MEMBER LEVEL 2β¦ plus the value gets a randomised FREE HAT!
add_one(1)
π
You have 30 days left of your FREE TRIAL!
π
Your MEMBER LEVEL is 3! Try watch_ad()!
π° Your MEGA COIN balance is now 19! Try watch_ad()!
π©
2
What a tease! Oh, and the stats are persistent, so your users canβt refresh their session and wipe the slate clean. Watch the cash roll in!
Free as in absolutely not
I hope this has been an inspirational eye-opener for you and that one day you can be as rich as me. Oh, you didnβt know I was rich? How else could I afford to keep this absolute juggernaut of a blog going?
To demonstrate how little I personally need them, here are some more ideas to maximise your financial rewards via R. You could try:
- releasing version updates as paid add-ons, like videogame DLC (you could also make them take several hours to download, like videogame DLC, which would definitely heighten the tension)
- loot boxes to allow users to gambleβI mean, test their precognitive skillsβfor new functionality (
add_two()could be a common drop, whilemultiply_by_two()is ultra rare) - using certified financial guru Duncan Garmonswayβs {ggbillboard} package (βuse vacant ggplot2 facets for advertisingβ)
You are welcome. Donβt read the small print for nerds.
Small print for nerds.
Itβs a simple trick: up-to-date stats are stored on the userβs computer in the directory resolved bytools::R_user_dir("monetize", "data")4 and are updated each time you use the functions in the package. Easy to circumventβ¦ if you know how.
Session info
## β Session info βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
## setting value
## version R version 4.3.1 (2023-06-16)
## os macOS Big Sur 11.6.7
## system x86_64, darwin20
## ui X11
## language (EN)
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Europe/London
## date 2023-07-31
## pandoc 3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
##
## β Packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
## package * version date (UTC) lib source
## blogdown 1.18 2023-06-19 [1] CRAN (R 4.3.0)
## bookdown 0.34 2023-05-09 [1] CRAN (R 4.3.0)
## bslib 0.5.0 2023-06-09 [1] CRAN (R 4.3.0)
## cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0)
## cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0)
## digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.0)
## evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.0)
## fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
## htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.3.0)
## jsonlite 1.8.5 2023-06-05 [1] CRAN (R 4.3.0)
## knitr 1.43 2023-05-25 [1] CRAN (R 4.3.0)
## monetize * 0.0.0.9000 2023-07-31 [1] Github (matt-dray/monetize@66201ff)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0)
## rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0)
## rmarkdown 2.22 2023-06-01 [1] CRAN (R 4.3.0)
## rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0)
## sass 0.4.6 2023-05-03 [1] CRAN (R 4.3.0)
## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
## xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0)
## yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0)
##
## [1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
##
## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Curious why they all start with βSβ? Itβs in deference to βRβ, which comes first in the alphabet and in being really cool.β©οΈ
Did you also know that the use of the New Zealand dollar is part of a wider conspiracy? The sheep dip goes deep on this one.β©οΈ
Donβt.β©οΈ
I consider this my hattrick of posts on
R_user_dir(). I wrote about it as a way to cache data from the PokΓ©API in {trapinch} and store cyber pet blueprints in {tamRgo}, the latter of which led to a post on saving high-score data with {hiscore}.β©οΈ