LoslegenKostenlos loslegen

Exploring data with predicates

We will continue our exploration of A/B test data. Your manager is not interested in which days reached the threshold, he wants to know if every day reached the threshold or if some days reached the threshold. We'll use purrr predicates to answer these questions.

You have received several thresholds and decided to write a script that will start with this threshold definition, and answer, for each design, if all the days have reached the threshold, and if not, if some did.

The results from this A/B test are in the all_visits list.

Diese Übung ist Teil des Kurses

Intermediate Functional Programming with purrr

Kurs anzeigen

Anleitung zur Übung

  • Create a variable called threshold, that contains the number 160.
  • Create a new mapper, that will test if .x is over threshold.
  • Combine map() and every() to test if all elements are over the threshold.
  • Combine map() and some() to test if some elements are over the threshold.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Create a threshold variable, set it to 160


# Create a mapper that tests if .x is over the defined threshold
over_threshold <- ___(~ .x > ___)

# Are all elements in every all_visits vectors over the defined threshold? 
map(all_visits, ~ ___(.x, ___))

# Are some elements in every all_visits vectors over the defined threshold? 
map(all_visits, ~ ___(.x, ___))
Code bearbeiten und ausführen