3-map reduce.txt - HW3 Map Reduce In this exercise we will use `map-reduce` to efficiently calculate means of large vectors from the `MplsStops` dataset

# 3-map reduce.txt - HW3 Map Reduce In this exercise we will...

• Homework Help
• 2

This preview shows page 1 - 2 out of 2 pages.

#' HW3: Map Reduce #' #' In this exercise, we will use `map-reduce` to efficiently calculate means of large vectors from the `MplsStops` dataset, contained in #' the package `carData`. The `MplsStops` dataset records all stops made by the Minneapolis Police Department for the year 2017. #' It contains 51857 observations with 14 variables.(Docs: ). #' #' #' 1. Load the packages `carData` and `purrr`. Select all the numeric columns from `MplsStops` dataset and store them in a variable `mpls_num`. #' (Hint: use the `keep(.x, .p)` function to select the correponding columns from dataset `.x` that satisfies the contraints defined in `.f`). ## Do not modify this line! library(carData) library(purrr) mpls_num<-keep(MplsStops,is.numeric) #' 2. Calculate the mean of each column and store them in a list `mpls_mean`. (Hint: Use `map_dbl()` and `mean()`.) #' Calculate the time it takes to calculate the mean and store it in a variable called `time1`.

#### You've reached the end of your free preview.

• Fall '18
• Linxi Liu
• Calculation, Column, Vector Motors, Minneapolis Police Department

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern