-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOPM_SPM.rmd
89 lines (68 loc) · 2.43 KB
/
OPM_SPM.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: "OPM_SPM_time.rmd"
author: "laetitia"
date: "11/6/2024"
output: html_document
---
*libraries needed
```{r}
library(readxl)
library(ggplot2)
library(lubridate)
```
*imported table OPM and SPM from excel
*cut out headers and footers and limited data to total pop by setting reading frame from A2:F62
```{r}
OPM_SPM_table <- read_excel("OPM_SPM.xlsx",
range = "A2:F62")
```
*renamed columns for convenience and overview
```{r}
colnames(OPM_SPM_table) <- c("year", "Anchored SPM Rate without Taxes/Transfers", "Anchored SPM", "Historical SPM without Taxes/Transfers", "SPM_Poverty_Rate", "OPM_Poverty_Rate" )
```
*deleted excessive superscript numbers from the years and substituted those values in the column Year
```{r}
OPM_SPM_table$year -> year
substring(year,1,4)
substring(year,1,4) ->OPM_SPM_table$year
```
*deleted rows 48, 52, 55 (duplicates)
```{r}
OPM_SPM_table <- OPM_SPM_table[-c (2,4,7,48, 52,55,56), ]
```
*assigning values and organizing data
```{r}
OPM_SPM_table$SPM_Poverty_Rate -> SPM_Poverty_Rate
OPM_SPM_table$year -> year
OPM_SPM_table$Date <- make_date(year)
make_date(year) -> Year
```
*starting to graph SPM vs Year
```{r}
ggplot(data=OPM_SPM_table,aes (x = Year, y = SPM_Poverty_Rate)) + geom_point(color=4) + geom_line(color=4) + theme_classic() + labs(title="Graph of SPM Poverty Rate vs. Year",
x ="Year", y = "SPM Poverty Rate")
```
*making graph SPM interactive for shiny
```{r echo = FALSE}
SPM_graph <- renderPlot({
ggplot(data=OPM_SPM_table,aes (x = Year, y = SPM_Poverty_Rate)) + geom_point(color=4) + geom_line(color=4) + theme_classic() + labs(title="Graph of SPM Poverty Rate vs. Year",
x ="Year", y = "SPM Poverty Rate")
})
```
*starting to graph OPM vs year
```{r}
OPM_SPM_table$OPM_Poverty_Rate -> OPM_Poverty_Rate
ggplot(data=OPM_SPM_table, aes (x = Year, y = OPM_Poverty_Rate)) + geom_point(color=4) + geom_line(color=4) + theme_classic() + labs(title="Graph of OPM Poverty Rate vs. Year",
x ="Year", y = "OPM Poverty Rate")
```
*making graph OPM interactive for shiny
```{r echo = FALSE}
OPM_graph <- renderPlot({
OPM_SPM_table$OPM_Poverty_Rate -> OPM_Poverty_Rate
ggplot(data=OPM_SPM_table, aes (x = Year, y = OPM_Poverty_Rate)) + geom_point(color=4) + geom_line(color=4) + theme_classic() + labs(title="Graph of OPM Poverty Rate vs. Year",
x ="Year", y = "OPM Poverty Rate")
})
```
```{r}
write.csv(OPM_SPM_table, file= "OPM_SPM_clean.csv")
```