-
Notifications
You must be signed in to change notification settings - Fork 1
/
import_wrangling_public_accounts_amo.R
71 lines (65 loc) · 4.33 KB
/
import_wrangling_public_accounts_amo.R
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
#Public Accts detailed information on acquisition of machinery and equipment
#data wrangling
library(tidyverse)
url_2023 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2023.csv"
url_2022 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2022.csv"
url_2021 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2021-eng.csv"
url_2020 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2020-eng.csv"
url_2019 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2019-eng.csv"
url_2018 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2018-eng.csv"
url_2017 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2017-eng.csv"
url_2016 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2016-eng.csv"
url_2015 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2015-eng.csv"
url_2014 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2014-eng.csv"
url_2013 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2013-eng.csv"
url_2012 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2012-eng.csv"
url_2011 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2011-eng.csv"
url_2010 <- "http://donnees-data.tpsgc-pwgsc.gc.ca/ba1/amo-ame/amo-ame-2010-eng.csv"
download.file(url_2022, "amo_2023.csv")
download.file(url_2022, "amo_2022.csv")
download.file(url_2021, "amo_2021.csv")
download.file(url_2020, "amo_2020.csv")
download.file(url_2019, "amo_2019.csv")
download.file(url_2018, "amo_2018.csv")
download.file(url_2017, "amo_2017.csv")
download.file(url_2016, "amo_2016.csv")
download.file(url_2015, "amo_2015.csv")
download.file(url_2014, "amo_2014.csv")
download.file(url_2013, "amo_2013.csv")
download.file(url_2012, "amo_2012.csv")
download.file(url_2011, "amo_2011.csv")
download.file(url_2010, "amo_2010.csv")
amo_dnd_2023 <- read_csv("amo_2023.csv") |> filter(DEPT_EN_DESC == "National Defence (Department of)")
amo_dnd_2022 <- read_csv("amo_2022.csv") |> filter(DEPT_EN_DESC == "National Defence (Department of)")
amo_dnd_2021 <- read_csv("amo_2021.csv") |> filter(DEPT_EN_DESC == "National Defence (Department of)")
amo_dnd_2020 <- read_csv("amo_2020.csv") |> filter(DEPT_EN_DESC == "National Defence (Department of)")
amo_dnd_2019 <- read_csv("amo_2019.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2018 <- read_csv("amo_2018.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2017 <- read_csv("amo_2017.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2016 <- read_csv("amo_2016.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2015 <- read_csv("amo_2015.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2014 <- read_csv("amo_2014.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2013 <- read_csv("amo_2013.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2012 <- read_csv("amo_2012.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2011 <- read_csv("amo_2011.csv") |> filter(DEPT_EN_DESC == "National Defence")
amo_dnd_2010 <- read_csv("amo_2010.csv") |> filter(DEPT_EN_DESC == "National Defence")
head(amo_dnd_2022)
head(amo_dnd_2010)#checking to see if column names match throughout - all good!
amo_2010to2020 <- bind_rows(amo_dnd_2010, amo_dnd_2011)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2012)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2013)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2014)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2015)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2016)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2017)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2018)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2019)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2020)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2021)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2022)
amo_2010to2020 <- bind_rows(amo_2010to2020, amo_dnd_2023)
save(amo_2010to2020, file = "amo_2010to2020.rda")#create RDA file containing the data
file.exists("amo_2010to2020.rda") #check to make sure it was successful
view(amo_2010to2020)
file.remove(c("amo_2023.csv", "amo_2022.csv", "amo_2021.csv", "amo_2020.csv", "amo_2019.csv", "amo_2018.csv", "amo_2017.csv", "amo_2016.csv", "amo_2015.csv", "amo_2014.csv", "amo_2013.csv", "amo_2012.csv", "amo_2011.csv", "amo_2010.csv"))
#clean up complete!