BaşlayınÜcretsiz Başlayın

Function to evaluate set of five years

In this exercise, we will write a function to evaluate any given set of five years, and check whether any individual has cashed in all five years.

We assume 6000 players, and each player will be represented by a number from 1 through 6000. Under the assumption that 10% of all players will cash, the input to the function will be a matrix with five columns, one for each year, and 600 rows, one per cashing player.

Bu egzersiz

Probability Puzzles in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use the Reduce function to find the intersection of all five years.
  • Check whether the intersection contains any elements.
  • Specify the conditional to indicate when FALSE should be returned.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

check_for_five <- function(cashed){
  # Find intersection of five years
  all_five <- Reduce(___)
  # Check intersection
  if(___){
    return(TRUE)
  # Specify when to return FALSE
  } ___ {
    return(FALSE)
  }
}
Kodu Düzenle ve Çalıştır