IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate Functional Programming with purrr

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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, ___))
Modifica ed esegui il codice