# Introduction to Data Science HW 4 ##### Copyright Jeffrey Stanton, Jeffrey Saltz, and Jasmina Tacheva ```{r} # Enter your name here: ``` ### Attribution statement: (choose only one and delete the...

1 answer below »
Please see attached


# Introduction to Data Science HW 4 ##### Copyright Jeffrey Stanton, Jeffrey Saltz, and Jasmina Tacheva ```{r} # Enter your name here: ``` ### Attribution statement: (choose only one and delete the rest) ```{r} # 1. I did this homework by myself, with help from the book and the professor. # 2. I did this homework with help from the book and the professor and these Internet sources: # 3. I did this homework with help from but did not cut and paste any code. ``` Reminders of things to practice from previous weeks: Descriptive statistics: mean( ) max( ) min( ) Coerce to numeric:as.numeric( ) ## Part 1: Use the Starter Code Below, I have provided a starter file to help you. Each of these lines of code **must be commented** (the comment must that explains what is going on, so that I know you understand the code and results). ```{r} library(jsonlite) dataset <- url("https://intro-datascience.s3.us-east-2.amazonaws.com/role.json")="" readlines=""><- jsonlite::fromjson(dataset)="" df=""><- readlines$objects$person="" ```="" a.="" explore="" the="" **df**="" dataframe="" (e.g.,="" using="" head()="" or="" whatever="" you="" think="" is="" best).="" ```{r}="" ```="" b.="" explain="" the="" dataset="" o="" what="" is="" the="" dataset="" about?="" o="" how="" many="" rows="" are="" there="" and="" what="" does="" a="" row="" represent?="" o="" how="" many="" columns="" and="" what="" does="" each="" column="" represent?="" ```{r}="" ```="" c.="" what="" does="" running="" this="" line="" of="" code="" do?="" explain="" in="" a="" comment:="" ```{r}="" vals=""><- substr(df$birthday,1,4) ``` d. create a new attribute 'age' - how old the person is **hint:** you may need to convert it to numeric first. ```{r} ``` e. create a function that reads in the role json dataset, and adds the age attribute to the dataframe, and returns that dataframe ```{r} ``` f. use (call, invoke) the function, and store the results in df ```{r} ``` ## part 2: investigate the resulting dataframe 'df' a.how many senators are women? ```{r} ``` b.how many senators have a youtube account? ```{r} ``` c. how many women senators have a youtube account? ```{r} ``` d.create a new dataframe called **youtubewomen** that only includes women senators who have a youtube account. ```{r} ``` e.make a histogram of the **age** of senators in **youtubewomen**, and then another for the senetors in **df**. add a comment describing the shape of the distributions. ```{r} ``` substr(df$birthday,1,4)="" ```="" d.="" create="" a="" new="" attribute="" 'age'="" -="" how="" old="" the="" person="" is="" **hint:**="" you="" may="" need="" to="" convert="" it="" to="" numeric="" first.="" ```{r}="" ```="" e.="" create="" a="" function="" that="" reads="" in="" the="" role="" json="" dataset,="" and="" adds="" the="" age="" attribute="" to="" the="" dataframe,="" and="" returns="" that="" dataframe="" ```{r}="" ```="" f.="" use="" (call,="" invoke)="" the="" function,="" and="" store="" the="" results="" in="" df="" ```{r}="" ```="" ##="" part="" 2:="" investigate="" the="" resulting="" dataframe="" 'df'="" a.="" how="" many="" senators="" are="" women?="" ```{r}="" ```="" b.="" how="" many="" senators="" have="" a="" youtube="" account?="" ```{r}="" ```="" c.="" how="" many="" women="" senators="" have="" a="" youtube="" account?="" ```{r}="" ```="" d.="" create="" a="" new="" dataframe="" called="" **youtubewomen**="" that="" only="" includes="" women="" senators="" who="" have="" a="" youtube="" account.="" ```{r}="" ```="" e.="" make="" a="" histogram="" of="" the="" **age**="" of="" senators="" in="" **youtubewomen**,="" and="" then="" another="" for="" the="" senetors="" in="" **df**.="" add="" a="" comment="" describing="" the="" shape="" of="" the="" distributions.="" ```{r}="">
Answered 11 days AfterNov 04, 2021

Answer To: # Introduction to Data Science HW 4 ##### Copyright Jeffrey Stanton, Jeffrey Saltz, and Jasmina...

Mohd answered on Nov 07 2021
110 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here