ComeçarComece de graça

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.

Este exercício faz parte do curso

Parallel Programming in R

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

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)
Editar e executar o código