Classwork 11

Part 1

(CW) What should be “cleaned up” about this data?

Some of the states and cities are missing. We could fill this data in using the latitude and longitude position.

Part 2

Code from class

# changing date format
ufos$datetime <- mdy_hm(ufos$datetime)

# adding column based on  string presence
ufos <- mutate(ufos, red = str_detect(tolower(comments), "red"))

# split string based on substring
ufos$split_city <- str_split_fixed(ufos$city, "\\(", 2)[ ,1]

ufos <- mutate(ufos, red = str_detect(tolower(comments), "red"))

Questions

UFO dataset

  1. (CW) Convert “date posted” to time format using lubridate
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” dplyr     1.1.4     âś” readr     2.1.6
## âś” forcats   1.0.1     âś” stringr   1.6.0
## âś” ggplot2   4.0.1     âś” tibble    3.3.1
## âś” lubridate 1.9.4     âś” tidyr     1.3.2
## âś” purrr     1.2.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## âś– dplyr::filter() masks stats::filter()
## âś– dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ufos = read.csv("ufo.csv")

head(ufos$date.posted)
## [1] "4/27/04"  "12/16/05" "1/21/08"  "1/17/04"  "1/22/04"  "4/27/07"
ufos = mutate(ufos, date.posted = mdy(date.posted))
head(ufos$date.posted)
## [1] "2004-04-27" "2005-12-16" "2008-01-21" "2004-01-17" "2004-01-22"
## [6] "2007-04-27"
  1. (CW) Add a binary column marking whether “green” appears in the comment
ufos = mutate(ufos, green = str_detect(tolower(comments), "green"))
head(select(ufos, c(green, comments)))
##   green
## 1 FALSE
## 2 FALSE
## 3  TRUE
## 4 FALSE
## 5 FALSE
## 6 FALSE
##                                                                                                                                                     comments
## 1                    This event took place in early fall around 1949-50. It occurred after a Boy Scout meeting in the Baptist Church. The Baptist Church sit
## 2                                                            1949 Lackland AFB&#44 TX.  Lights racing across the sky &amp; making 90 degree turns on a dime.
## 3                                                                                                        Green/Orange circular disc over Chester&#44 England
## 4                 My older brother and twin sister were leaving the only Edna theater at about 9 PM&#44...we had our bikes and I took a different route home
## 5 AS a Marine 1st Lt. flying an FJ4B fighter/attack aircraft on a solo night exercise&#44 I was at 50&#44000&#39 in a &quot;clean&quot; aircraft (no ordinan
## 6                 My father is now 89 my brother 52 the girl with us now 51 myself 49 and the other fellow which worked with my father if he&#39s still livi
  1. Create the split_city column using the code above

not answered.

ufos <- mutate(ufos, state = recode(state, tx = "Texas"))
ufos <- mutate(ufos, state = recode(state, tx = "Texas", ct="Connecticut"))

ufos <- mutate(ufos, red = str_detect(tolower(comments), "red"))
ufos <- mutate(ufos, red = recode(as.character(red), `TRUE`="red", `FALSE`="not red"))
  1. (CW) Test out the code above. What does recode do?
head(ufos)
##         datetime                 city state country    shape duration..seconds.
## 1 10/10/49 20:30           san marcos Texas      us cylinder               2700
## 2 10/10/49 21:00         lackland afb Texas            light               7200
## 3 10/10/55 17:00 chester (uk/england)            gb   circle                 20
## 4 10/10/56 21:00                 edna Texas      us   circle                 20
## 5 10/10/60 20:00              kaneohe    hi      us    light                900
## 6 10/10/61 19:00              bristol    tn      us   sphere                300
##   duration..hours.min.
## 1           45 minutes
## 2              1-2 hrs
## 3           20 seconds
## 4             1/2 hour
## 5           15 minutes
## 6            5 minutes
##                                                                                                                                                     comments
## 1                    This event took place in early fall around 1949-50. It occurred after a Boy Scout meeting in the Baptist Church. The Baptist Church sit
## 2                                                            1949 Lackland AFB&#44 TX.  Lights racing across the sky &amp; making 90 degree turns on a dime.
## 3                                                                                                        Green/Orange circular disc over Chester&#44 England
## 4                 My older brother and twin sister were leaving the only Edna theater at about 9 PM&#44...we had our bikes and I took a different route home
## 5 AS a Marine 1st Lt. flying an FJ4B fighter/attack aircraft on a solo night exercise&#44 I was at 50&#44000&#39 in a &quot;clean&quot; aircraft (no ordinan
## 6                 My father is now 89 my brother 52 the girl with us now 51 myself 49 and the other fellow which worked with my father if he&#39s still livi
##   date.posted   latitude   longitude green     red
## 1  2004-04-27 29.8830556  -97.941111 FALSE     red
## 2  2005-12-16   29.38421  -98.581082 FALSE not red
## 3  2008-01-21       53.2   -2.916667  TRUE not red
## 4  2004-01-17 28.9783333  -96.645833 FALSE not red
## 5  2004-01-22 21.4180556 -157.803611 FALSE not red
## 6  2007-04-27     36.595  -82.188889 FALSE not red

It seems to change states that have a value of “tx” to become “Texas”. Additionally, if the state is “tx” it becomes “Texas” (which was already done previously), and also if the state is “ct”, it becomes “Connecticut”. The next part adds a column called red that detects if the comment has the word red in it. The next line turns “TRUE” and “FALSE” to “red” and “not red”, respectively.

Salary dataset

Salary dataset: * Link: https://drive.google.com/file/d/13hbUjFdFctywrX4q3QkhJvw90kUdm1mr/view?usp=sharing * Description: https://www.kaggle.com/datasets/thedevastator/jobs-dataset-from-glassdoor

  1. (CW) Create a column with an integer of the lower-bound salary estimate
jobs = read_csv("glassdoor_jobs.csv")
## New names:
## Rows: 956 Columns: 15
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (12): Job Title, Salary Estimate, Job Description, Company Name, Locatio... dbl
## (3): ...1, Rating, Founded
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
head(jobs)
## # A tibble: 6 Ă— 15
##    ...1 `Job Title`    `Salary Estimate` `Job Description` Rating `Company Name`
##   <dbl> <chr>          <chr>             <chr>              <dbl> <chr>         
## 1     0 Data Scientist $53K-$91K (Glass… "Data Scientist\…    3.8 "Tecolote Res…
## 2     1 Healthcare Da… $63K-$112K (Glas… "What You Will D…    3.4 "University o…
## 3     2 Data Scientist $80K-$90K (Glass… "KnowBe4, Inc. i…    4.8 "KnowBe4\n4.8"
## 4     3 Data Scientist $56K-$97K (Glass… "*Organization a…    3.8 "PNNL\n3.8"   
## 5     4 Data Scientist $86K-$143K (Glas… "Data Scientist\…    2.9 "Affinity Sol…
## 6     5 Data Scientist $71K-$119K (Glas… "CyrusOne is see…    3.4 "CyrusOne\n3.…
## # ℹ 9 more variables: Location <chr>, Headquarters <chr>, Size <chr>,
## #   Founded <dbl>, `Type of ownership` <chr>, Industry <chr>, Sector <chr>,
## #   Revenue <chr>, Competitors <chr>
jobs$lower_est = str_split_fixed(jobs$`Salary Estimate`, "-", 2)[,1]
head(jobs$lower_est)
## [1] "$53K" "$63K" "$80K" "$56K" "$86K" "$71K"
  1. Create a column with an integer for a lower bound of the company size
  2. (CW) Create a binary column by searching for a word or phrase in the “job description” column
jobs <- mutate(jobs, strtest = str_detect(tolower(`Job Description`), "data analytics"))
head( select( jobs, c(strtest, `Job Description`) ) )
## # A tibble: 6 Ă— 2
##   strtest `Job Description`                                                     
##   <lgl>   <chr>                                                                 
## 1 FALSE   "Data Scientist\nLocation: Albuquerque, NM\nEducation Required: Bache…
## 2 FALSE   "What You Will Do:\n\nI. General Summary\n\nThe Healthcare Data Scien…
## 3 TRUE    "KnowBe4, Inc. is a high growth information security company. We are …
## 4 FALSE   "*Organization and Job ID**\nJob ID: 310709\n\nDirectorate: Earth & B…
## 5 TRUE    "Data Scientist\nAffinity Solutions / Marketing Cloud seeks smart, cu…
## 6 FALSE   "CyrusOne is seeking a talented Data Scientist who holds a range of d…
  1. Create a column with an integer for the lower-bound revenue of the company

Part 3

  1. (CW) What are some rules for good presentation design?
  • Make font size large and readable
  • Avoid visually complex fonts
  • Use accessible color palettes
  • Don’t put too many words on the slide
  • Don’t put too many images on the slide
    • Can reserve important images for their own dedicated slide
  1. (CW) What could be improved about this slide? example plot
  • The Welch Two test image is bad. Small text and too much detail.
  • I feel like the graph should have more emphasis. It is also too hard to read, and I think faceting might fix the issue.
  1. (CW) Edit this slide: https://docs.google.com/presentation/d/19xaPgleIdoQljLajZKLnaLMqWuIQJ4mjfsvHn68XZWM/edit#slide=id.g213f6dc73df_0_59.
  2. (CW) Compare poster presentations to slide presentations: What are pros and cons of each?
  • Slides has more (infinite) space to work with while a poster has a limited amount of space.
  • All information on a poster is visible at all times while slides only display parts of the information.
  • Posters invite conversation between the audience and speaker.
  1. Work on designing the slides/poster for your project.