SensorTowerR v0.2.3 introduces automatic revenue standardization across all functions. This guide helps you migrate existing code to use the new standardized revenue columns.
Previously, different SensorTowerR functions returned revenue in different units:
- st_top_charts(): cents (revenue_absolute)
- st_sales_report(): dollars (total_revenue)
- st_top_publishers(): cents (revenue_absolute)
Now, all functions provide standardized revenue columns in base currency units (dollars for USD, euros for EUR, etc.).
Before v0.2.3:
top_games <- st_top_charts(...)
top_games %>%
mutate(revenue_dollars = revenue_absolute / 100)
After v0.2.3:
top_games <- st_top_charts(...)
# Use the 'revenue' column directly - it's already in dollars
top_games %>%
select(app_name, revenue)
No changes needed - This function already returned values in base currency units.
Before v0.2.3:
publishers <- st_top_publishers(...)
publishers %>%
mutate(revenue_dollars = revenue_absolute / 100)
After v0.2.3:
publishers <- st_top_publishers(...)
# Use 'revenue_usd' column directly
publishers %>%
select(publisher_name, revenue_usd)
If your code needs to work with both old and new versions:
# For st_top_charts()
process_revenue <- function(data) {
if ("revenue" %in% names(data)) {
# v0.2.3+ - use standardized column
data$revenue_millions <- data$revenue / 1e6
} else {
# Pre-v0.2.3 - manual conversion
data$revenue_millions <- data$revenue_absolute / 100 / 1e6
}
return(data)
}
top_games <- st_top_charts(...) %>%
process_revenue()
Old code:
mutate(revenue_millions = revenue_absolute / 1e8) # cents to millions
New code:
mutate(revenue_millions = revenue / 1e6) # dollars to millions
Old code:
mutate(revenue_fmt = scales::dollar(revenue_absolute / 100))
New code:
mutate(revenue_fmt = scales::dollar(revenue))
Old code:
gini_coef <- calculate_gini(data$revenue_absolute / 100)
New code:
gini_coef <- calculate_gini(data$revenue)
# Check if you have v0.2.3+
if (packageVersion("SensorTowerR") >= "0.2.3") {
message("You have the standardized revenue version!")
} else {
message("Please update: devtools::install_github('econosopher/SensorTowerR')")
}
inst/docs/revenue_units_guide.mdinst/examples/revenue_standardization_example.RAny scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.