Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data manipulation using R Download and load Most_popular_baby_name.csv to R using the following R code: library(' tidyverse ') baby_names

Data manipulation using R

Download and load Most_popular_baby_name.csv to R using the following R code:

library('tidyverse') baby_names <- read_csv("http://personal.stevens.edu/~fmai/data/Most_Popular_Baby_Names.csv")

The file contains the counts of baby names by sex and mother's ethnicity in NYC in 2011-2014. For example, the first record indicates that in 2011, when the mother is Hispanic and the baby is female, 13 were named GERALDINE. BRTH_YR Gender ETHCTY Name Count 2011 FEMALE HISPANIC GERALDINE 13

Only analyze the dataset for the years 2012 - 2014, so filter/subset the dataset accordingly:

baby_names <- baby_names %>% filter(BRTH_YR >= 2012)

Note that in some years, names are recorded in lower cases and while in others the names are recorded in upper cases. Find a way to standardize the names.

For the 2012-2014 data, answer the following questions. You may use base R, dplyr package or sqldf package:

a. What is the total number of UNIQUE names in the dataset?

Hint: for base R, consider using unique() and length() function. For dplyr, you can chain distinct(Name) and nrow() together. The answer is between 1500 and 1600.

b. Assuming that the ethnicity is non-overlapping, for each year, calculate the total number of babies born for each ethnicity in the dataset. The 2013 statistics should look like this: 1 2013 ASIAN AND PACIFIC ISLANDER 9293 2 2013 BLACK NON HISPANIC ???? 3 2013 HISPANIC ???? 4 2013 WHITE NON HISPANIC ????

Hint: for dplyr, consider chaining group_by(BRTH_YR, ETHCTY) and summarise(sum(Count))

c. During 2012-2014, what are the top 3 most popular baby names in each year?. For example, the 3 most popular names in 2012 are:

BRTH_YR Name Total

2012 ethan 723 2012 jacob 641 2012 jayden 752

Hint: For each year-name combination, you need to calculate the total counts across gender and ethnicity.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago