ComenzarEmpieza gratis

Lambda functions

We are still working with the results of a weeklong A/B test on a website. The three vectors containing the number of visits for each design (visit_a, visit_b and visit_c) are available in your workspace.

One of your colleagues has asked you to transfer him the results, but he wants them to be rounded to the nearest ten. To do this, you will need to call the round() function this way:

Rounding to a negative number of digits means rounding to a power of ten, so for example round(x, digits = -2) rounds to the nearest hundred

Definition taken from R documentation: see ?round

Make sure to use the right map_* for each call.

Este ejercicio forma parte del curso

Intermediate Functional Programming with purrr

Ver curso

Instrucciones del ejercicio

  • Round visit_a to the nearest ten with a mapper.
  • Create a reusable mapper object called to_ten, that rounds to the nearest ten.
  • Map to_ten to visit_b.
  • Map to_ten to visit_c.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Round visit_a to the nearest tenth with a mapper
___(visit_a, ~ ___(.x, -1))

# Create to_ten, a mapper that rounds to the nearest tenth
to_ten <- ___(~ ___(.x, ___))

# Map to_ten on visit_b
___(visit_b, ___)

# Map to_ten on visit_c
___(visit_c, ___)
Editar y ejecutar código