Get startedGet started for free

Funding social sciences with futures

You work for a philanthropic foundation. The foundation awards research grants to universities with a social sciences research rating among the top one percent in their country. Therefore, each year a cutoff value for the research rating is calculated.

You have a list, rating_list, in your workspace. Each element contains research ratings for universities in a country. You also have generate_cutoff_future() available. This function creates a future for the calculation of the cutoff value. However, your manager is not so sure about the advantage of futures over other parallelization methods. You have to demonstrate that futures enable sequential and parallel execution without making changes to the actual code. The future package has been loaded for you.

This exercise is part of the course

Parallel Programming in R

View Course

Exercise instructions

  • Generate sequential futures by applying generate_cutoff_future() to rating_list using lapply() under a sequential plan.
  • Extract the values of the sequential futures.
  • Generate parallel futures under a parallel plan.
  • Extract values of the parallel futures.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

plan(sequential)
# Create futures under sequential plan
seq_futures <- ___(___, ___)
# Extract values of sequential futures
seq_values <- ___(___)

plan(multisession, workers = 4)
# Create futures under multisession plan
par_futures <- ___(___, ___)
# Extract values of parallel futures
par_values <- ___(___)
               
plan(sequential)

cbind(seq_values, par_values)
Edit and Run Code