Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

--- title: "Assignment One" author: "Professor Lepore" date: "9/08/2022" output: html_document --- # *Task(s):* - ***[1]*** Run the chunks labeled with help_screen, read the help tab, refer to our...

1 answer below »

---
title: "Assignment One"
author: "Professor Lepore"
date: "9/08/2022"
output: html_document
---
# *Task(s):*
- ***[1]*** Run the chunks labeled with help_screen, read the help tab, refe
to our week one lesson lessons, look at the resources in the syllabus, and then
in your own words write a summary of what this function does. [5 Points]
- ***[2]*** Scroll down to the 'Examples' section of the help tab to see the
examples provided. Then create your own example for how to use these functions.
Make sure to 'comment' # on what's happening in your example. [5 Points]
- ***[3]*** When turning in your assignment please attach both this RMD file and the
html knitted file. I've already set the specific chunk settings for this assignment.
Also be sure to rename both as assignment_one_first_lastname.
- ***[4]*** Extra point (1): Make your HTML document aesthetically pleasing by
using RMARKDOWN syntax:
https:
www.rstudio.com/wp-content/uploads/2015/02
markdown-cheatsheet.pdf
- Partial credit points are possible with tasks one and two.
# AS CHARACTER
```{r as_character_help_screen, eval=FALSE, include=TRUE}
?"as.character"
```
## Summary of function as.character()
Your summary goes here, delete this line and type out your summary in the white space.
```{r example_of_as_character}
# Example:
```
# AS LOGICAL
```{r as_logical_help_screen, eval=FALSE, include=TRUE}
?"as.logical"
```
## Summary of function as.logical()
Your summary goes here, delete this line and type out your summary in the white space.
```{r example_of_as_logical}
# Example:
```
# AS NUMERIC
```{r as_numeric_help_screen, eval=FALSE, include=TRUE}
?"as.numeric"
```
## Summary of function as.numeric()
Your summary goes here, delete this line and type out your summary in the white space.
```{r example_of_as_numeric}
# Example:
```
# c()
```{r c_help_screen, eval=FALSE, include=TRUE}
?"c"
```
## Summary of function c()
Your summary goes here, delete this line and type out your summary in the white space.
```{r example_of_c}
# Example:
```
# list()
```{r list_help_screen, eval=FALSE, include=TRUE}
?"list"
```
## Summary of function list()
Your summary goes here, delete this line and type out your summary in the white space.
```{r example_of_list}
# Example:
```

---
title: "Assignment Two"
author: "Professor Lepore"
date: "9/15/2022"
output: html_document
---
# *Task(s):*
- ***[1]*** Select and rename the columns/variables [2 Points]
- ***[2]*** Mutate the data frame [5 Points]
- ***[3]*** Count and average, describe the results [3 Points]
- ***[4]*** When turning in your assignment please attach both this RMD file
and the html knitted file. I've already set the specific chunk settings for
this assignment. Also be sure to rename both as assignment_two_first_lastname.
### Extra points (3)
- (1): Make your HTML document aesthetically pleasing by using RMARKDOWN syntax:
https:
www.rstudio.com/wp-content/uploads/2015/02
markdown-cheatsheet.pdf
- (2): Describe the logic behind your mutates and replacements
Partial credit points are possible with tasks two and three.
# R [PART ONE]
```{r setup, include = TRUE}
# Chunk Options ----------------------------------------------------------------
knitr::opts_chunk$set(
    echo = TRUE
)
# R PACKAGES -------------------------------------------------------------------
if (!require('tidyverse'))
install.packages('tidyverse',
XXXXXXXXXXrepos = "http:
cran.us.r-project.org");
li
ary('tidyverse')
if (!require('reticulate'))
install.packages('reticulate',
XXXXXXXXXXrepos = "http:
cran.us.r-project.org");
li
ary('reticulate')
```
```{r data_import}
homebase_data <- jsonlite::fromJSON("https:
data.cityofnewyork.us
esource/ntcm-2w4k.json?$limit=200")
```
```{r data_inspection}
head(homebase_data)
tail(homebase_data)
summary(homebase_data)
colnames(homebase_data)
```
```{r data_cleaning}
# Create the object homebase_data_clean and make sure to:
# 1. Select the following columns/variables:
# (homebase_office, service_area_zip_code, postcode)
# 2. Rename: service_area_zip_code to servicing_zipcodes and
# postcode to homebase_location_zipcode
homebase_data_clean <- homebase_data
```
```{r data_cleaning_part_two}
# Mutate the object homebase_data_clean with the following:
# 1. homebase_office capitalized
# 2. Remove the I, II, and III from the homebase office names
# Hint: We need to use a string replacement and trimming white space
# 3. Replace the servicing_zipcodes with any co
ections
# 4. Find the number of servicing_zipcodes
homebase_data_clean <- homebase_data_clean
```
```{r hints, eval=FALSE}
# Possible functions for 2:
?"str_replace_all"
?"gsub"
?"trimws"
?"str_trim"
```
```{r simple_stats}
# Perform a count by homebase_office
# Find the mean number of zipcodes per organization
# Describe the number of homebase offices each organization has and on average
# how many zipcodes each organization services.
```
# Results:
# Python [PART TWO]
```{python setup_python}
# Python PACKAGES --------------------------------------------------------------
import json
import requests
import pandas as pd
pd.options.mode.chained_assignment = None # default='warn'
```
```{python data_import_python}
json_link = requests.get('https:
data.cityofnewyork.us
esource/ntcm-2w4k.json?$limit=200')
json_loaded = json.loads(json_link.text)
homebase_data_python = pd.DataFrame(json_loaded)
```
```{python data_inspection_python}
homebase_data_python.head(5)
homebase_data_python.tail(5)
homebase_data_python.dtypes
list(homebase_data_python.columns)
```
```{python data_cleaning_python}
# Create the object homebase_data_clean and make sure to:
# 1. Select the following columns/variables:
# (homebase_office, service_area_zip_code, postcode)
# 2. Rename: service_area_zip_code to servicing_zipcodes and
# postcode to homebase_location_zipcode
```
```{python data_cleaning_part_two_python}
# Mutate the object homebase_data_clean with the following:
# 1. homebase_office capitalized
# 2. Remove the I, II, and III from the homebase office names
# Hint: We need to use a string replacement and trimming white space
# 3. Replace the servicing_zipcodes with any co
ections
# 4. Find the number of servicing_zipcodes

```
```{python hints_python, eval = FALSE}
# Possible functions for 2:
str.replace?
str.strip?
```
```{python simple_stats_python}
# Perform a count by homebase_office
# Find the mean number of zipcodes per homebase organization
```
Answered 4 days After Sep 08, 2022

Solution

Monica answered on Sep 13 2022
64 Votes
Python Result:
homebase_office ... homebase_location_zipcode
0 ARCHNY ... 10472
1 ARCHNY ... 10474
2 ARCHNY ... 10466
3 ARCHNY ... 10467
4 BRONXWORKS ... 10456
5 BRONXWORKS ... 10455
6 HELP ... 10460
7 HELP ... 10457
8 HELP ... 10467
9 HELP ... 10453
10 ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here