Skip to content

Commit c433138

Browse files
committedJun 11, 2023
first draft of a tidy tuesday
1 parent adf356d commit c433138

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: "TidyTuesday Week 19: Portal Project"
3+
description: "TidyTuesday: Rodents of Portal Arizona"
4+
twitter-card:
5+
image: "thumbnail.png"
6+
author:
7+
- name: Louise E. Sinks
8+
url: https://lsinks.github.io/
9+
date: 05-09-2023
10+
categories: [R, TidyTuesday, R-code, Code-Along, Data-Viz, data validation, exploratory data analysis] # self-defined categories
11+
citation:
12+
url: https://lsinks.github.io/posts/2023-05-09-tidytuesday-childcare/childcare
13+
image: "thumbnail.png"
14+
draft: true # setting this to `true` will prevent your post from appearing on your listing page until you're ready!
15+
---
16+
17+
Today's TidyTuesday is about childcare prices.
18+
19+
```{r}
20+
21+
library(tidyverse)
22+
library(gt)
23+
library(skimr)
24+
```
25+
26+
Loading the data in the usual way.
27+
28+
```{r}
29+
tuesdata <- tidytuesdayR::tt_load(2023, week = 19)
30+
31+
childcare_costs <- tuesdata$childcare_costs
32+
counties <- tuesdata$counties
33+
```
34+
35+
There are two data files. The dataframe counties has information about county and state, while childcare_costs has a variety of economic data for each county over several years (2008 - 2018). The two dataframes can be joined on county_fips_code, which is a unique identifier for every county. If you look at the TidyTuesday notes, they actually started out in a single file and were split up.
36+
37+
```{r}
38+
labor_rates <- childcare_costs %>%
39+
select(study_year, county_fips_code, flfpr_20to64, flfpr_20to64_under6, mc_infant, mfcc_infant )
40+
```
41+
42+
```{r}
43+
labor_rates_2 <- labor_rates %>%
44+
left_join(counties)
45+
```
46+
47+
```{r}
48+
#| column: page
49+
50+
my_skim <- skim_with(numeric = sfl(p25 = NULL, p50 = NULL, p75 = NULL))
51+
52+
my_skim(labor_rates_2)
53+
```
54+
55+
Employment gap between all women and women with young children
56+
57+
```{r}
58+
labor_rates_2 <- labor_rates_2 %>%
59+
mutate(gap = flfpr_20to64 - flfpr_20to64_under6)
60+
```
61+
62+
average cost of infant care
63+
64+
```{r}
65+
labor_rates_2 <- labor_rates_2 %>%
66+
mutate(cost = (mc_infant + mfcc_infant)/2)
67+
```
68+
69+
plot gap vs. cost for 2018
70+
71+
```{r}
72+
labor_rates_2 %>%
73+
# filter(study_year == 2018) %>%
74+
ggplot(aes(cost, gap, color = study_year)) +
75+
geom_point() + geom_smooth()
76+
```
77+
78+
correlation
79+
80+
```{r}
81+
82+
labor_rates_2_2018 <- labor_rates_2 %>%
83+
filter(study_year == 2018)
84+
cor(labor_rates_2_2018$gap, labor_rates_2_2018$cost, use = "pairwise.complete.obs")
85+
86+
```

0 commit comments

Comments
 (0)
Please sign in to comment.