Exercise

# Exercise 1. Sample average

Write function called `take_sample`

that takes the proportion of Democrats \(p\) and the sample size \(N\) as arguments and returns the sample average of Democrats (1) and Republicans (0).

Calculate the sample average if the proportion of Democrats equals 0.45 and the sample size is 100.

Instructions

**100 XP**

- Define a function called
`take_sample`

that takes \(p\) and \(N\) as arguments. - Use the
`sample`

function as the first statement in your function to sample \(N\) elements from a vector of options where Democrats are assigned the value '1' and Republicans are assigned the value '0' in that order. - Use the
`mean`

function as the second statement in your function to find the average value of the random sample.