Exercise

Simulating Data with Purrr

Often when trying to solve a problem with data we first need to build some simulated data to see if our idea is even possible. For example, you may want to test models with data that have known differences, to see if the models are working correctly.

In this exercise, you will see how this works in purrr by simulating data for two populations, a and b, from the sites: "north", "east", and "west". The two populations will be randomly drawn from a normal distribution, with different means and standard deviations.

Instructions

100 XP
  • Create a list of site names, "north", "east", and "west".
  • Then use map() to create a list of data frames with three columns, the first column is sites.
    • The second is population a, which has a mean of 5, a sample size n of 200, and an sd of (5/2).
    • The third is population b, which has a mean of 200, a sample size n of 200, and an sd of 15.