Futures for advertisement targets
An online streaming platform has hired you as a Data Analyst. Every quarter, they launch a marketing campaign for the highest-spending segment of their customers. To correctly target this campaign to the right users, they want to generate distributions for the average monthly revenue from users across different groups. They have already segmented their customers based on factors such as geography, estimated income, etc.
In your workspace, you have a list, subs_list
. Each element of this list is a vector of monthly subscription payments for one segment of customers. The function, boot_dist()
, is also available. This function bootstraps a distribution for the average revenue. That must be applied to each element of subs_list
. The future
package has been loaded for you.
This exercise is part of the course
Parallel Programming in R
Exercise instructions
- Plan a multisession with four workers.
- Using
lapply()
, create a future for every mapping ofboot_dist()
onto an element ofsubs_list
. - Query the value of each future in
future_list
. - Revert to a sequential plan.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plan a multisession
___(___, ___)
# Create futures for every bootstrap
future_list <- ___(___, function (x) ___(boot_dist(x)))
# Query value of futures
dist_list <- ___(___)
# Revert to sequential plan
___(___)