Code
library(tidyverse)
library(lubridate)
library(summarytools)
Error in library(summarytools): there is no package called 'summarytools'
Code
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Sai Venkatesh
April 27, 2023
Error in library(summarytools): there is no package called 'summarytools'
Today’s challenge is to:
Read in one (or more) of the following datasets, using the correct R package and command.
We will be reading the Fed Funds Rate data.
Year Month Day Federal.Funds.Target.Rate Federal.Funds.Upper.Target
1 1954 7 1 NA NA
2 1954 8 1 NA NA
3 1954 9 1 NA NA
4 1954 10 1 NA NA
5 1954 11 1 NA NA
6 1954 12 1 NA NA
Federal.Funds.Lower.Target Effective.Federal.Funds.Rate
1 NA 0.80
2 NA 1.22
3 NA 1.06
4 NA 0.85
5 NA 0.83
6 NA 1.28
Real.GDP..Percent.Change. Unemployment.Rate Inflation.Rate
1 4.6 5.8 NA
2 NA 6.0 NA
3 NA 6.1 NA
4 8.0 5.7 NA
5 NA 5.3 NA
6 NA 5.0 NA
[1] 904 10
[1] "Year" "Month"
[3] "Day" "Federal.Funds.Target.Rate"
[5] "Federal.Funds.Upper.Target" "Federal.Funds.Lower.Target"
[7] "Effective.Federal.Funds.Rate" "Real.GDP..Percent.Change."
[9] "Unemployment.Rate" "Inflation.Rate"
The data consists of the Fed Funds Rate and it has 904 rows and 10 columns. The columns include Federal Funds Target rate, Upper and Lower Target, Real GDP, Unemployment and Inflation rate. There also seems to be a lot of NA values. This maybe since the data would not have been available during those years.
[1] "Lets see the NA counts by columns"
[1] "Year"
[1] 0
[1] "Month"
[1] 0
[1] "Day"
[1] 0
[1] "Federal.Funds.Target.Rate"
[1] 442
[1] "Federal.Funds.Upper.Target"
[1] 801
[1] "Federal.Funds.Lower.Target"
[1] 801
[1] "Effective.Federal.Funds.Rate"
[1] 152
[1] "Real.GDP..Percent.Change."
[1] 654
[1] "Unemployment.Rate"
[1] 152
[1] "Inflation.Rate"
[1] 194
Seems like there are a lot of NA values for Real.GDP..Percent.Change. column. But since we are going to use date and those columns are 0, we can go ahead without tidying.
We can reduce the date variables of Year, Month and Day and combine them for date based analysis. This can then be reordered.
We will then do analysis of the data and try to extract the date vise Unemployment vs Inflation Rate to see the correlation.
Min. 1st Qu. Median Mean 3rd Qu. Max.
"1954-07-01" "1973-04-23" "1987-12-16" "1987-02-25" "2001-06-07" "2017-03-16"
summarizedData <- fed_funds_data %>%
group_by(Year) %>%
summarize(MeanOfTargetRate = mean(`Federal.Funds.Target.Rate`, na.rm=TRUE),
MeanOfUpperTarget = mean(`Federal.Funds.Upper.Target`, na.rm = TRUE),
MeanOfLowerTarget = mean(`Federal.Funds.Lower.Target`, na.rm = TRUE))
print(summarizedData, n=100)
# A tibble: 64 × 4
Year MeanOfTargetRate MeanOfUpperTarget MeanOfLowerTarget
<int> <dbl> <dbl> <dbl>
1 1954 NaN NaN NaN
2 1955 NaN NaN NaN
3 1956 NaN NaN NaN
4 1957 NaN NaN NaN
5 1958 NaN NaN NaN
6 1959 NaN NaN NaN
7 1960 NaN NaN NaN
8 1961 NaN NaN NaN
9 1962 NaN NaN NaN
10 1963 NaN NaN NaN
11 1964 NaN NaN NaN
12 1965 NaN NaN NaN
13 1966 NaN NaN NaN
14 1967 NaN NaN NaN
15 1968 NaN NaN NaN
16 1969 NaN NaN NaN
17 1970 NaN NaN NaN
18 1971 NaN NaN NaN
19 1972 NaN NaN NaN
20 1973 NaN NaN NaN
21 1974 NaN NaN NaN
22 1975 NaN NaN NaN
23 1976 NaN NaN NaN
24 1977 NaN NaN NaN
25 1978 NaN NaN NaN
26 1979 NaN NaN NaN
27 1980 NaN NaN NaN
28 1981 NaN NaN NaN
29 1982 9.39 NaN NaN
30 1983 9.05 NaN NaN
31 1984 10.2 NaN NaN
32 1985 8.04 NaN NaN
33 1986 6.74 NaN NaN
34 1987 6.65 NaN NaN
35 1988 7.46 NaN NaN
36 1989 9.18 NaN NaN
37 1990 7.91 NaN NaN
38 1991 5.55 NaN NaN
39 1992 3.52 NaN NaN
40 1993 3 NaN NaN
41 1994 4.11 NaN NaN
42 1995 5.82 NaN NaN
43 1996 5.27 NaN NaN
44 1997 5.44 NaN NaN
45 1998 5.3 NaN NaN
46 1999 5.03 NaN NaN
47 2000 6.17 NaN NaN
48 2001 3.96 NaN NaN
49 2002 1.67 NaN NaN
50 2003 1.12 NaN NaN
51 2004 1.43 NaN NaN
52 2005 3.17 NaN NaN
53 2006 4.92 NaN NaN
54 2007 4.97 NaN NaN
55 2008 2.21 0.25 0
56 2009 NaN 0.25 0
57 2010 NaN 0.25 0
58 2011 NaN 0.25 0
59 2012 NaN 0.25 0
60 2013 NaN 0.25 0
61 2014 NaN 0.25 0
62 2015 NaN 0.269 0.0192
63 2016 NaN 0.519 0.269
64 2017 NaN 0.812 0.562
Date Unemployment.Rate Inflation.Rate
1 1954-07-01 5.8 NA
2 1954-08-01 6.0 NA
3 1954-09-01 6.1 NA
4 1954-10-01 5.7 NA
5 1954-11-01 5.3 NA
6 1954-12-01 5.0 NA
7 1955-01-01 4.9 NA
8 1955-02-01 4.7 NA
9 1955-03-01 4.6 NA
10 1955-04-01 4.7 NA
11 1955-05-01 4.3 NA
12 1955-06-01 4.2 NA
13 1955-07-01 4.0 NA
14 1955-08-01 4.2 NA
15 1955-09-01 4.1 NA
16 1955-10-01 4.3 NA
17 1955-11-01 4.2 NA
18 1955-12-01 4.2 NA
19 1956-01-01 4.0 NA
20 1956-02-01 3.9 NA
21 1956-03-01 4.2 NA
22 1956-04-01 4.0 NA
23 1956-05-01 4.3 NA
24 1956-06-01 4.3 NA
25 1956-07-01 4.4 NA
26 1956-08-01 4.1 NA
27 1956-09-01 3.9 NA
28 1956-10-01 3.9 NA
29 1956-11-01 4.3 NA
30 1956-12-01 4.2 NA
31 1957-01-01 4.2 NA
32 1957-02-01 3.9 NA
33 1957-03-01 3.7 NA
34 1957-04-01 3.9 NA
35 1957-05-01 4.1 NA
36 1957-06-01 4.3 NA
37 1957-07-01 4.2 NA
38 1957-08-01 4.1 NA
39 1957-09-01 4.4 NA
40 1957-10-01 4.5 NA
41 1957-11-01 5.1 NA
42 1957-12-01 5.2 NA
43 1958-01-01 5.8 3.2
44 1958-02-01 6.4 3.2
45 1958-03-01 6.7 2.8
46 1958-04-01 7.4 2.4
47 1958-05-01 7.4 2.4
48 1958-06-01 7.3 2.1
49 1958-07-01 7.5 2.4
50 1958-08-01 7.4 2.1
51 1958-09-01 7.1 1.7
52 1958-10-01 6.7 1.7
53 1958-11-01 6.2 1.7
54 1958-12-01 6.2 1.7
55 1959-01-01 6.0 1.7
56 1959-02-01 5.9 1.7
57 1959-03-01 5.6 1.7
58 1959-04-01 5.2 1.7
59 1959-05-01 5.1 2.0
60 1959-06-01 5.0 2.0
61 1959-07-01 5.1 2.0
62 1959-08-01 5.2 2.0
63 1959-09-01 5.5 2.4
64 1959-10-01 5.7 2.7
65 1959-11-01 5.8 2.0
66 1959-12-01 5.3 2.0
67 1960-01-01 5.2 2.0
68 1960-02-01 4.8 2.3
69 1960-03-01 5.4 2.0
70 1960-04-01 5.2 2.0
71 1960-05-01 5.1 1.7
72 1960-06-01 5.4 1.7
73 1960-07-01 5.5 1.3
74 1960-08-01 5.6 1.3
75 1960-09-01 5.5 1.0
76 1960-10-01 6.1 1.0
77 1960-11-01 6.1 1.0
78 1960-12-01 6.6 1.0
79 1961-01-01 6.6 1.0
80 1961-02-01 6.9 0.7
81 1961-03-01 6.9 0.7
82 1961-04-01 7.0 1.0
83 1961-05-01 7.1 1.0
84 1961-06-01 6.9 1.0
85 1961-07-01 7.0 1.3
86 1961-08-01 6.6 1.3
87 1961-09-01 6.7 1.6
88 1961-10-01 6.5 1.3
89 1961-11-01 6.1 1.3
90 1961-12-01 6.0 1.3
91 1962-01-01 5.8 1.3
92 1962-02-01 5.5 1.3
93 1962-03-01 5.6 1.6
94 1962-04-01 5.6 1.3
95 1962-05-01 5.5 1.6
96 1962-06-01 5.5 1.6
97 1962-07-01 5.4 1.3
98 1962-08-01 5.7 1.3
99 1962-09-01 5.6 1.3
100 1962-10-01 5.4 1.3
101 1962-11-01 5.7 1.3
102 1962-12-01 5.5 1.3
103 1963-01-01 5.7 1.0
104 1963-02-01 5.9 1.0
105 1963-03-01 5.7 1.0
106 1963-04-01 5.7 1.3
107 1963-05-01 5.9 1.0
108 1963-06-01 5.6 1.3
109 1963-07-01 5.6 1.3
110 1963-08-01 5.4 1.6
111 1963-09-01 5.5 1.3
112 1963-10-01 5.5 1.3
113 1963-11-01 5.7 1.6
114 1963-12-01 5.5 1.6
115 1964-01-01 5.6 1.9
116 1964-02-01 5.4 1.9
117 1964-03-01 5.4 1.9
118 1964-04-01 5.3 1.6
119 1964-05-01 5.1 1.6
120 1964-06-01 5.2 1.6
121 1964-07-01 4.9 1.6
122 1964-08-01 5.0 0.9
123 1964-09-01 5.1 1.3
124 1964-10-01 5.1 1.3
125 1964-11-01 4.8 1.2
126 1964-12-01 5.0 1.2
127 1965-01-01 4.9 1.6
128 1965-02-01 5.1 1.6
129 1965-03-01 4.7 1.2
130 1965-04-01 4.8 1.6
131 1965-05-01 4.6 1.6
132 1965-06-01 4.6 1.2
133 1965-07-01 4.4 1.2
134 1965-08-01 4.4 1.6
135 1965-09-01 4.3 1.5
136 1965-10-01 4.2 1.5
137 1965-11-01 4.1 1.2
138 1965-12-01 4.0 1.5
139 1966-01-01 4.0 0.9
140 1966-02-01 3.8 1.2
141 1966-03-01 3.8 1.5
142 1966-04-01 3.8 1.8
143 1966-05-01 3.9 2.1
144 1966-06-01 3.8 2.4
145 1966-07-01 3.8 2.8
146 1966-08-01 3.8 3.1
147 1966-09-01 3.7 3.0
148 1966-10-01 3.7 3.3
149 1966-11-01 3.6 3.6
150 1966-12-01 3.8 3.3
151 1967-01-01 3.9 3.6
152 1967-02-01 3.8 3.6
153 1967-03-01 3.8 3.6
154 1967-04-01 3.8 3.3
155 1967-05-01 3.8 3.3
156 1967-06-01 3.9 3.3
157 1967-07-01 3.8 3.3
158 1967-08-01 3.8 3.3
159 1967-09-01 3.8 3.6
160 1967-10-01 4.0 3.5
161 1967-11-01 3.9 3.5
162 1967-12-01 3.8 3.8
163 1968-01-01 3.7 4.1
164 1968-02-01 3.8 4.1
165 1968-03-01 3.7 4.4
166 1968-04-01 3.5 4.4
167 1968-05-01 3.5 4.3
168 1968-06-01 3.7 4.6
169 1968-07-01 3.7 4.9
170 1968-08-01 3.5 4.9
171 1968-09-01 3.4 4.9
172 1968-10-01 3.4 4.8
173 1968-11-01 3.4 5.1
174 1968-12-01 3.4 5.1
175 1969-01-01 3.4 5.1
176 1969-02-01 3.4 5.3
177 1969-03-01 3.4 5.6
178 1969-04-01 3.4 6.1
179 1969-05-01 3.4 6.1
180 1969-06-01 3.5 5.8
181 1969-07-01 3.5 5.8
182 1969-08-01 3.5 5.8
183 1969-09-01 3.7 6.0
184 1969-10-01 3.7 6.0
185 1969-11-01 3.5 5.9
186 1969-12-01 3.5 6.2
187 1970-01-01 3.9 6.2
188 1970-02-01 4.2 6.1
189 1970-03-01 4.4 6.1
190 1970-04-01 4.6 5.8
191 1970-05-01 4.8 6.0
192 1970-06-01 4.9 6.5
193 1970-07-01 5.0 6.2
194 1970-08-01 5.1 6.2
195 1970-09-01 5.4 6.2
196 1970-10-01 5.5 6.4
197 1970-11-01 5.9 6.6
198 1970-12-01 6.1 6.6
199 1971-01-01 5.9 6.3
200 1971-02-01 5.9 5.8
201 1971-03-01 6.0 5.2
202 1971-04-01 5.9 5.0
203 1971-05-01 5.9 5.2
204 1971-06-01 5.9 4.9
205 1971-07-01 6.0 4.9
206 1971-08-01 6.1 4.6
207 1971-09-01 6.0 4.4
208 1971-10-01 5.8 3.8
209 1971-11-01 6.0 3.3
210 1971-12-01 6.0 3.1
211 1972-01-01 5.8 3.1
212 1972-02-01 5.7 3.3
213 1972-03-01 5.8 3.3
214 1972-04-01 5.7 3.3
215 1972-05-01 5.7 3.1
216 1972-06-01 5.7 2.8
217 1972-07-01 5.6 2.8
218 1972-08-01 5.6 3.3
219 1972-09-01 5.5 2.8
220 1972-10-01 5.6 3.0
221 1972-11-01 5.3 3.0
222 1972-12-01 5.2 3.0
223 1973-01-01 4.9 2.8
224 1973-02-01 5.0 2.8
225 1973-03-01 4.9 3.0
226 1973-04-01 5.0 3.2
227 1973-05-01 4.9 3.2
228 1973-06-01 4.9 3.2
229 1973-07-01 4.8 3.2
230 1973-08-01 4.8 3.2
231 1973-09-01 4.8 3.8
232 1973-10-01 4.6 4.3
233 1973-11-01 4.8 4.5
234 1973-12-01 4.9 4.7
235 1974-01-01 5.1 4.9
236 1974-02-01 5.2 5.4
237 1974-03-01 5.1 5.8
238 1974-04-01 5.1 6.2
239 1974-05-01 5.1 6.8
240 1974-06-01 5.4 7.9
241 1974-07-01 5.5 8.8
242 1974-08-01 5.5 9.6
243 1974-09-01 5.9 10.2
244 1974-10-01 6.0 10.6
245 1974-11-01 6.6 11.2
246 1974-12-01 7.2 11.1
247 1975-01-01 8.1 11.5
248 1975-02-01 8.1 11.7
249 1975-03-01 8.6 11.4
250 1975-04-01 8.8 11.3
251 1975-05-01 9.0 10.5
252 1975-06-01 8.8 9.6
253 1975-07-01 8.6 9.1
254 1975-08-01 8.4 8.2
255 1975-09-01 8.4 7.7
256 1975-10-01 8.4 7.0
257 1975-11-01 8.3 6.8
258 1975-12-01 8.2 6.7
259 1976-01-01 7.9 6.7
260 1976-02-01 7.7 6.5
261 1976-03-01 7.6 6.6
262 1976-04-01 7.7 6.4
263 1976-05-01 7.4 6.5
264 1976-06-01 7.6 6.5
265 1976-07-01 7.8 6.7
266 1976-08-01 7.8 6.8
267 1976-09-01 7.6 6.8
268 1976-10-01 7.7 6.7
269 1976-11-01 7.8 6.5
270 1976-12-01 7.8 6.1
271 1977-01-01 7.5 6.3
272 1977-02-01 7.6 6.3
273 1977-03-01 7.4 6.2
274 1977-04-01 7.2 6.3
275 1977-05-01 7.0 6.3
276 1977-06-01 7.2 6.6
277 1977-07-01 6.9 6.3
278 1977-08-01 7.0 6.2
279 1977-09-01 6.8 6.2
280 1977-10-01 6.8 6.0
281 1977-11-01 6.8 5.9
282 1977-12-01 6.4 6.5
283 1978-01-01 6.4 6.4
284 1978-02-01 6.3 6.2
285 1978-03-01 6.3 6.3
286 1978-04-01 6.1 6.5
287 1978-05-01 6.0 6.8
288 1978-06-01 5.9 7.0
289 1978-07-01 6.2 7.4
290 1978-08-01 5.9 7.5
291 1978-09-01 6.0 7.9
292 1978-10-01 5.8 8.4
293 1978-11-01 5.9 8.7
294 1978-12-01 6.0 8.5
295 1979-01-01 5.9 8.6
296 1979-02-01 5.9 9.2
297 1979-03-01 5.8 9.3
298 1979-04-01 5.8 9.3
299 1979-05-01 5.6 9.4
300 1979-06-01 5.7 9.3
301 1979-07-01 5.7 9.6
302 1979-08-01 6.0 10.0
303 1979-09-01 5.9 9.9
304 1979-10-01 6.0 10.1
305 1979-11-01 5.9 10.6
306 1979-12-01 6.0 11.3
307 1980-01-01 6.3 12.0
308 1980-02-01 6.3 12.0
309 1980-03-01 6.3 12.5
310 1980-04-01 6.9 13.0
311 1980-05-01 7.5 13.3
312 1980-06-01 7.6 13.6
313 1980-07-01 7.8 12.4
314 1980-08-01 7.7 11.8
315 1980-09-01 7.5 12.0
316 1980-10-01 7.5 12.3
317 1980-11-01 7.5 12.1
318 1980-12-01 7.2 12.2
319 1981-01-01 7.5 11.4
320 1981-02-01 7.4 10.9
321 1981-03-01 7.4 10.0
322 1981-04-01 7.2 9.5
323 1981-05-01 7.5 9.5
324 1981-06-01 7.5 9.4
325 1981-07-01 7.2 11.1
326 1981-08-01 7.4 11.6
327 1981-09-01 7.6 11.8
328 1981-10-01 7.9 10.9
329 1981-11-01 8.3 10.2
330 1981-12-01 8.5 9.5
331 1982-01-01 8.6 9.3
332 1982-02-01 8.9 9.1
333 1982-03-01 9.0 8.8
334 1982-04-01 9.3 8.9
335 1982-05-01 9.4 8.7
336 1982-06-01 9.6 8.6
337 1982-07-01 9.8 7.6
338 1982-08-01 9.8 7.1
339 1982-09-01 10.1 5.9
340 1982-09-27 NA NA
341 1982-10-01 10.4 5.9
342 1982-10-07 NA NA
343 1982-11-01 10.8 5.3
344 1982-11-19 NA NA
345 1982-12-01 10.8 4.5
346 1982-12-14 NA NA
347 1983-01-01 10.4 4.7
348 1983-02-01 10.4 4.7
349 1983-03-01 10.3 4.7
350 1983-03-31 NA NA
351 1983-04-01 10.2 4.3
352 1983-05-01 10.1 3.6
353 1983-05-25 NA NA
354 1983-06-01 10.1 2.9
355 1983-06-24 NA NA
356 1983-07-01 9.4 3.0
357 1983-07-14 NA NA
358 1983-07-20 NA NA
359 1983-08-01 9.5 3.0
360 1983-08-11 NA NA
361 1983-08-17 NA NA
362 1983-09-01 9.2 3.5
363 1983-09-15 NA NA
364 1983-10-01 8.8 3.7
365 1983-11-01 8.5 4.3
366 1983-12-01 8.3 4.8
367 1984-01-01 8.0 4.8
368 1984-02-01 7.8 4.8
369 1984-03-01 7.8 5.0
370 1984-03-29 NA NA
371 1984-04-01 7.7 5.0
372 1984-05-01 7.4 5.2
373 1984-06-01 7.2 5.1
374 1984-07-01 7.5 5.0
375 1984-07-05 NA NA
376 1984-07-19 NA NA
377 1984-08-01 7.5 5.1
378 1984-08-09 NA NA
379 1984-09-01 7.3 5.1
380 1984-09-20 NA NA
381 1984-09-27 NA NA
382 1984-10-01 7.4 4.9
383 1984-10-11 NA NA
384 1984-10-18 NA NA
385 1984-11-01 7.2 4.6
386 1984-11-08 NA NA
387 1984-11-23 NA NA
388 1984-12-01 7.3 4.7
389 1984-12-06 NA NA
390 1984-12-19 NA NA
391 1984-12-24 NA NA
392 1985-01-01 7.3 4.5
393 1985-01-24 NA NA
394 1985-02-01 7.2 4.7
395 1985-02-14 NA NA
396 1985-03-01 7.2 4.8
397 1985-03-28 NA NA
398 1985-04-01 7.3 4.5
399 1985-04-25 NA NA
400 1985-05-01 7.2 4.5
401 1985-05-20 NA NA
402 1985-06-01 7.4 4.4
403 1985-07-01 7.4 4.2
404 1985-07-11 NA NA
405 1985-08-01 7.1 4.1
406 1985-08-21 NA NA
407 1985-09-01 7.1 4.0
408 1985-09-06 NA NA
409 1985-10-01 7.1 4.1
410 1985-11-01 7.0 4.4
411 1985-12-01 7.0 4.3
412 1985-12-18 NA NA
413 1986-01-01 6.7 4.4
414 1986-02-01 7.2 4.2
415 1986-03-01 7.2 4.1
416 1986-03-07 NA NA
417 1986-04-01 7.1 4.2
418 1986-04-02 NA NA
419 1986-04-21 NA NA
420 1986-05-01 7.2 4.0
421 1986-05-22 NA NA
422 1986-06-01 7.2 4.0
423 1986-06-05 NA NA
424 1986-07-01 7.0 4.1
425 1986-07-11 NA NA
426 1986-08-01 6.9 4.0
427 1986-08-21 NA NA
428 1986-09-01 7.0 4.1
429 1986-10-01 7.0 4.0
430 1986-11-01 6.9 3.8
431 1986-12-01 6.6 3.8
432 1987-01-01 6.6 3.8
433 1987-01-05 NA NA
434 1987-02-01 6.6 3.8
435 1987-03-01 6.6 4.0
436 1987-04-01 6.3 4.2
437 1987-04-30 NA NA
438 1987-05-01 6.3 4.2
439 1987-05-22 NA NA
440 1987-06-01 6.2 4.1
441 1987-07-01 6.1 4.0
442 1987-07-02 NA NA
443 1987-08-01 6.0 4.2
444 1987-08-27 NA NA
445 1987-09-01 5.9 4.3
446 1987-09-03 NA NA
447 1987-09-04 NA NA
448 1987-09-24 NA NA
449 1987-10-01 6.0 4.3
450 1987-11-01 5.8 4.4
451 1987-11-04 NA NA
452 1987-12-01 5.7 4.2
453 1988-01-01 5.7 4.3
454 1988-01-28 NA NA
455 1988-02-01 5.7 4.3
456 1988-02-11 NA NA
457 1988-03-01 5.7 4.4
458 1988-03-30 NA NA
459 1988-04-01 5.4 4.3
460 1988-05-01 5.6 4.3
461 1988-05-09 NA NA
462 1988-05-25 NA NA
463 1988-06-01 5.4 4.5
464 1988-06-22 NA NA
465 1988-07-01 5.4 4.5
466 1988-07-19 NA NA
467 1988-08-01 5.6 4.4
468 1988-08-08 NA NA
469 1988-08-09 NA NA
470 1988-09-01 5.4 4.4
471 1988-10-01 5.4 4.5
472 1988-11-01 5.3 4.4
473 1988-11-17 NA NA
474 1988-11-22 NA NA
475 1988-12-01 5.3 4.7
476 1988-12-15 NA NA
477 1989-01-01 5.4 4.6
478 1989-01-05 NA NA
479 1989-02-01 5.2 4.8
480 1989-02-09 NA NA
481 1989-02-14 NA NA
482 1989-02-24 NA NA
483 1989-03-01 5.0 4.7
484 1989-04-01 5.2 4.6
485 1989-05-01 5.2 4.6
486 1989-05-17 NA NA
487 1989-06-01 5.3 4.5
488 1989-06-06 NA NA
489 1989-07-01 5.2 4.6
490 1989-07-07 NA NA
491 1989-07-27 NA NA
492 1989-08-01 5.2 4.4
493 1989-09-01 5.3 4.3
494 1989-10-01 5.3 4.3
495 1989-10-19 NA NA
496 1989-11-01 5.4 4.4
497 1989-11-06 NA NA
498 1989-12-01 5.4 4.4
499 1989-12-20 NA NA
500 1990-01-01 5.4 4.4
501 1990-02-01 5.3 4.6
502 1990-03-01 5.2 4.9
503 1990-04-01 5.4 4.8
504 1990-05-01 5.4 4.8
505 1990-06-01 5.2 4.9
506 1990-07-01 5.5 5.0
507 1990-07-13 NA NA
508 1990-08-01 5.7 5.5
509 1990-09-01 5.9 5.5
510 1990-10-01 5.9 5.3
511 1990-10-29 NA NA
512 1990-11-01 6.2 5.3
513 1990-11-14 NA NA
514 1990-12-01 6.3 5.2
515 1990-12-07 NA NA
516 1990-12-19 NA NA
517 1991-01-01 6.4 5.6
518 1991-01-09 NA NA
519 1991-02-01 6.6 5.6
520 1991-03-01 6.8 5.2
521 1991-03-08 NA NA
522 1991-04-01 6.7 5.1
523 1991-04-30 NA NA
524 1991-05-01 6.9 5.1
525 1991-06-01 6.9 5.0
526 1991-07-01 6.8 4.8
527 1991-08-01 6.9 4.6
528 1991-08-06 NA NA
529 1991-09-01 6.9 4.5
530 1991-09-13 NA NA
531 1991-10-01 7.0 4.4
532 1991-10-31 NA NA
533 1991-11-01 7.0 4.5
534 1991-11-06 NA NA
535 1991-12-01 7.3 4.4
536 1991-12-06 NA NA
537 1991-12-20 NA NA
538 1992-01-01 7.3 3.9
539 1992-02-01 7.4 3.8
540 1992-03-01 7.4 3.9
541 1992-04-01 7.4 3.9
542 1992-04-09 NA NA
543 1992-05-01 7.6 3.8
544 1992-06-01 7.8 3.8
545 1992-07-01 7.7 3.7
546 1992-07-02 NA NA
547 1992-08-01 7.6 3.5
548 1992-09-01 7.6 3.3
549 1992-09-04 NA NA
550 1992-10-01 7.3 3.5
551 1992-11-01 7.4 3.4
552 1992-12-01 7.4 3.3
553 1993-01-01 7.3 3.5
554 1993-02-01 7.1 3.6
555 1993-03-01 7.0 3.4
556 1993-04-01 7.1 3.5
557 1993-05-01 7.1 3.4
558 1993-06-01 7.0 3.3
559 1993-07-01 6.9 3.2
560 1993-08-01 6.8 3.3
561 1993-09-01 6.7 3.2
562 1993-10-01 6.8 3.0
563 1993-11-01 6.6 3.1
564 1993-12-01 6.5 3.2
565 1994-01-01 6.6 2.9
566 1994-02-01 6.6 2.8
567 1994-02-04 NA NA
568 1994-03-01 6.5 2.9
569 1994-03-22 NA NA
570 1994-04-01 6.4 2.8
571 1994-04-18 NA NA
572 1994-05-01 6.1 2.8
573 1994-05-17 NA NA
574 1994-06-01 6.1 2.9
575 1994-07-01 6.1 2.9
576 1994-08-01 6.0 2.9
577 1994-08-16 NA NA
578 1994-09-01 5.9 3.0
579 1994-10-01 5.8 2.9
580 1994-11-01 5.6 2.8
581 1994-11-15 NA NA
582 1994-12-01 5.5 2.6
583 1995-01-01 5.6 2.9
584 1995-02-01 5.4 3.0
585 1995-03-01 5.4 3.0
586 1995-04-01 5.8 3.1
587 1995-05-01 5.6 3.1
588 1995-06-01 5.6 3.0
589 1995-07-01 5.7 3.0
590 1995-07-06 NA NA
591 1995-08-01 5.7 2.9
592 1995-09-01 5.6 2.9
593 1995-10-01 5.5 3.0
594 1995-11-01 5.6 3.0
595 1995-12-01 5.6 3.0
596 1995-12-19 NA NA
597 1996-01-01 5.6 3.0
598 1996-01-31 NA NA
599 1996-02-01 5.5 2.9
600 1996-03-01 5.5 2.8
601 1996-04-01 5.6 2.7
602 1996-05-01 5.6 2.7
603 1996-06-01 5.3 2.7
604 1996-07-01 5.5 2.7
605 1996-08-01 5.1 2.6
606 1996-09-01 5.2 2.7
607 1996-10-01 5.2 2.6
608 1996-11-01 5.4 2.6
609 1996-12-01 5.4 2.6
610 1997-01-01 5.3 2.5
611 1997-02-01 5.2 2.5
612 1997-03-01 5.2 2.5
613 1997-03-25 NA NA
614 1997-04-01 5.1 2.7
615 1997-05-01 4.9 2.5
616 1997-06-01 5.0 2.4
617 1997-07-01 4.9 2.4
618 1997-08-01 4.8 2.3
619 1997-09-01 4.9 2.2
620 1997-10-01 4.7 2.3
621 1997-11-01 4.6 2.2
622 1997-12-01 4.7 2.2
623 1998-01-01 4.6 2.2
624 1998-02-01 4.6 2.3
625 1998-03-01 4.7 2.1
626 1998-04-01 4.3 2.1
627 1998-05-01 4.4 2.2
628 1998-06-01 4.5 2.2
629 1998-07-01 4.5 2.2
630 1998-08-01 4.5 2.5
631 1998-09-01 4.6 2.5
632 1998-09-29 NA NA
633 1998-10-01 4.5 2.3
634 1998-10-15 NA NA
635 1998-11-01 4.4 2.3
636 1998-11-17 NA NA
637 1998-12-01 4.4 2.4
638 1999-01-01 4.3 2.4
639 1999-02-01 4.4 2.1
640 1999-03-01 4.2 2.1
641 1999-04-01 4.3 2.2
642 1999-05-01 4.2 2.0
643 1999-06-01 4.3 2.1
644 1999-06-30 NA NA
645 1999-07-01 4.3 2.1
646 1999-08-01 4.2 1.9
647 1999-08-24 NA NA
648 1999-09-01 4.2 2.0
649 1999-10-01 4.1 2.1
650 1999-11-01 4.1 2.1
651 1999-11-16 NA NA
652 1999-12-01 4.0 1.9
653 2000-01-01 4.0 2.0
654 2000-02-01 4.1 2.2
655 2000-02-02 NA NA
656 2000-03-01 4.0 2.4
657 2000-03-21 NA NA
658 2000-04-01 3.8 2.3
659 2000-05-01 4.0 2.4
660 2000-05-16 NA NA
661 2000-06-01 4.0 2.5
662 2000-07-01 4.0 2.5
663 2000-08-01 4.1 2.6
664 2000-09-01 3.9 2.6
665 2000-10-01 3.9 2.5
666 2000-11-01 3.9 2.6
667 2000-12-01 3.9 2.6
668 2001-01-01 4.2 2.6
669 2001-01-03 NA NA
670 2001-01-31 NA NA
671 2001-02-01 4.2 2.7
672 2001-03-01 4.3 2.7
673 2001-03-20 NA NA
674 2001-04-01 4.4 2.6
675 2001-04-18 NA NA
676 2001-05-01 4.3 2.5
677 2001-05-15 NA NA
678 2001-06-01 4.5 2.7
679 2001-06-27 NA NA
680 2001-07-01 4.6 2.7
681 2001-08-01 4.9 2.7
682 2001-08-21 NA NA
683 2001-09-01 5.0 2.6
684 2001-09-17 NA NA
685 2001-10-01 5.3 2.6
686 2001-10-02 NA NA
687 2001-11-01 5.5 2.8
688 2001-11-06 NA NA
689 2001-12-01 5.7 2.7
690 2001-12-11 NA NA
691 2002-01-01 5.7 2.6
692 2002-02-01 5.7 2.6
693 2002-03-01 5.7 2.4
694 2002-04-01 5.9 2.5
695 2002-05-01 5.8 2.5
696 2002-06-01 5.8 2.3
697 2002-07-01 5.8 2.2
698 2002-08-01 5.7 2.4
699 2002-09-01 5.7 2.2
700 2002-10-01 5.7 2.2
701 2002-11-01 5.9 2.0
702 2002-11-06 NA NA
703 2002-12-01 6.0 1.9
704 2003-01-01 5.8 1.9
705 2003-02-01 5.9 1.7
706 2003-03-01 5.9 1.7
707 2003-04-01 6.0 1.5
708 2003-05-01 6.1 1.6
709 2003-06-01 6.3 1.5
710 2003-06-25 NA NA
711 2003-07-01 6.2 1.5
712 2003-08-01 6.1 1.3
713 2003-09-01 6.1 1.2
714 2003-10-01 6.0 1.3
715 2003-11-01 5.8 1.1
716 2003-12-01 5.7 1.1
717 2004-01-01 5.7 1.1
718 2004-02-01 5.6 1.2
719 2004-03-01 5.8 1.6
720 2004-04-01 5.6 1.8
721 2004-05-01 5.6 1.7
722 2004-06-01 5.6 1.9
723 2004-06-30 NA NA
724 2004-07-01 5.5 1.8
725 2004-08-01 5.4 1.7
726 2004-08-10 NA NA
727 2004-09-01 5.4 2.0
728 2004-09-21 NA NA
729 2004-10-01 5.5 2.0
730 2004-11-01 5.4 2.2
731 2004-11-10 NA NA
732 2004-12-01 5.4 2.2
733 2004-12-14 NA NA
734 2005-01-01 5.3 2.3
735 2005-02-01 5.4 2.4
736 2005-02-02 NA NA
737 2005-03-01 5.2 2.3
738 2005-03-22 NA NA
739 2005-04-01 5.2 2.2
740 2005-05-01 5.1 2.2
741 2005-05-03 NA NA
742 2005-06-01 5.0 2.0
743 2005-06-30 NA NA
744 2005-07-01 5.0 2.1
745 2005-08-01 4.9 2.1
746 2005-08-09 NA NA
747 2005-09-01 5.0 2.0
748 2005-09-20 NA NA
749 2005-10-01 5.0 2.1
750 2005-11-01 5.0 2.1
751 2005-12-01 4.9 2.2
752 2005-12-13 NA NA
753 2006-01-01 4.7 2.1
754 2006-01-31 NA NA
755 2006-02-01 4.8 2.1
756 2006-03-01 4.7 2.1
757 2006-03-28 NA NA
758 2006-04-01 4.7 2.3
759 2006-05-01 4.6 2.4
760 2006-05-10 NA NA
761 2006-06-01 4.6 2.6
762 2006-06-29 NA NA
763 2006-07-01 4.7 2.7
764 2006-08-01 4.7 2.8
765 2006-09-01 4.5 2.9
766 2006-10-01 4.4 2.7
767 2006-11-01 4.5 2.6
768 2006-12-01 4.4 2.6
769 2007-01-01 4.6 2.7
770 2007-02-01 4.5 2.7
771 2007-03-01 4.4 2.5
772 2007-04-01 4.5 2.3
773 2007-05-01 4.4 2.2
774 2007-06-01 4.6 2.2
775 2007-07-01 4.7 2.2
776 2007-08-01 4.6 2.1
777 2007-09-01 4.7 2.1
778 2007-09-18 NA NA
779 2007-10-01 4.7 2.2
780 2007-10-31 NA NA
781 2007-11-01 4.7 2.3
782 2007-12-01 5.0 2.4
783 2007-12-11 NA NA
784 2008-01-01 5.0 2.5
785 2008-01-22 NA NA
786 2008-01-30 NA NA
787 2008-02-01 4.9 2.3
788 2008-03-01 5.1 2.4
789 2008-03-18 NA NA
790 2008-04-01 5.0 2.3
791 2008-04-30 NA NA
792 2008-05-01 5.4 2.3
793 2008-06-01 5.6 2.4
794 2008-07-01 5.8 2.5
795 2008-08-01 6.1 2.5
796 2008-09-01 6.1 2.5
797 2008-10-01 6.5 2.2
798 2008-10-08 NA NA
799 2008-10-29 NA NA
800 2008-11-01 6.8 2.0
801 2008-12-01 7.3 1.8
802 2008-12-16 NA NA
803 2009-01-01 7.8 1.7
804 2009-02-01 8.3 1.8
805 2009-03-01 8.7 1.8
806 2009-04-01 9.0 1.9
807 2009-05-01 9.4 1.8
808 2009-06-01 9.5 1.7
809 2009-07-01 9.5 1.5
810 2009-08-01 9.6 1.4
811 2009-09-01 9.8 1.5
812 2009-10-01 10.0 1.7
813 2009-11-01 9.9 1.7
814 2009-12-01 9.9 1.8
815 2010-01-01 9.8 1.6
816 2010-02-01 9.8 1.3
817 2010-03-01 9.9 1.1
818 2010-04-01 9.9 0.9
819 2010-05-01 9.6 0.9
820 2010-06-01 9.4 0.9
821 2010-07-01 9.4 0.9
822 2010-08-01 9.5 0.9
823 2010-09-01 9.5 0.8
824 2010-10-01 9.4 0.6
825 2010-11-01 9.8 0.8
826 2010-12-01 9.3 0.8
827 2011-01-01 9.1 1.0
828 2011-02-01 9.0 1.1
829 2011-03-01 9.0 1.2
830 2011-04-01 9.1 1.3
831 2011-05-01 9.0 1.5
832 2011-06-01 9.1 1.6
833 2011-07-01 9.0 1.8
834 2011-08-01 9.0 2.0
835 2011-09-01 9.0 2.0
836 2011-10-01 8.8 2.1
837 2011-11-01 8.6 2.2
838 2011-12-01 8.5 2.2
839 2012-01-01 8.3 2.3
840 2012-02-01 8.3 2.2
841 2012-03-01 8.2 2.3
842 2012-04-01 8.2 2.3
843 2012-05-01 8.2 2.3
844 2012-06-01 8.2 2.2
845 2012-07-01 8.2 2.1
846 2012-08-01 8.1 1.9
847 2012-09-01 7.8 2.0
848 2012-10-01 7.8 2.0
849 2012-11-01 7.7 1.9
850 2012-12-01 7.9 1.9
851 2013-01-01 8.0 1.9
852 2013-02-01 7.7 2.0
853 2013-03-01 7.5 1.9
854 2013-04-01 7.6 1.7
855 2013-05-01 7.5 1.7
856 2013-06-01 7.5 1.6
857 2013-07-01 7.3 1.7
858 2013-08-01 7.3 1.8
859 2013-09-01 7.2 1.7
860 2013-10-01 7.2 1.7
861 2013-11-01 6.9 1.7
862 2013-12-01 6.7 1.7
863 2014-01-01 6.6 1.6
864 2014-02-01 6.7 1.6
865 2014-03-01 6.7 1.7
866 2014-04-01 6.2 1.8
867 2014-05-01 6.3 2.0
868 2014-06-01 6.1 1.9
869 2014-07-01 6.2 1.9
870 2014-08-01 6.2 1.7
871 2014-09-01 5.9 1.7
872 2014-10-01 5.7 1.8
873 2014-11-01 5.8 1.7
874 2014-12-01 5.6 1.6
875 2015-01-01 5.7 1.6
876 2015-02-01 5.5 1.7
877 2015-03-01 5.4 1.8
878 2015-04-01 5.4 1.8
879 2015-05-01 5.5 1.7
880 2015-06-01 5.3 1.8
881 2015-07-01 5.2 1.8
882 2015-08-01 5.1 1.8
883 2015-09-01 5.0 1.9
884 2015-10-01 5.0 1.9
885 2015-11-01 5.0 2.0
886 2015-12-01 5.0 2.1
887 2015-12-16 NA NA
888 2016-01-01 4.9 2.2
889 2016-02-01 4.9 2.3
890 2016-03-01 5.0 2.2
891 2016-04-01 5.0 2.1
892 2016-05-01 4.7 2.2
893 2016-06-01 4.9 2.2
894 2016-07-01 4.9 2.2
895 2016-08-01 4.9 2.3
896 2016-09-01 4.9 2.2
897 2016-10-01 4.8 2.1
898 2016-11-01 4.6 2.1
899 2016-12-01 4.7 2.2
900 2016-12-14 NA NA
901 2017-01-01 4.8 2.3
902 2017-02-01 4.7 2.2
903 2017-03-01 NA NA
904 2017-03-16 NA NA
---
title: "Challenge 4"
author: "Sai Venkatesh"
description: "More data wrangling: pivoting"
date: "04/27/2023"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge_4
- abc_poll
- eggs
- fed_rates
- hotel_bookings
- debt
---
```{r}
#| label: setup
#| warning: false
#| message: false
library(tidyverse)
library(lubridate)
library(summarytools)
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```
## Challenge Overview
Today's challenge is to:
1) read in a data set, and describe the data set using both words and any supporting information (e.g., tables, etc)
2) tidy data (as needed, including sanity checks)
3) identify variables that need to be mutated
4) mutate variables and sanity check all mutations
## Read in data
Read in one (or more) of the following datasets, using the correct R package and command.
- abc_poll.csv ⭐
- poultry_tidy.xlsx or organiceggpoultry.xls⭐⭐
- FedFundsRate.csv⭐⭐⭐
- hotel_bookings.csv⭐⭐⭐⭐
- debt_in_trillions.xlsx ⭐⭐⭐⭐⭐
We will be reading the Fed Funds Rate data.
```{r}
fed_funds_data <- read.csv('_data/FedFundsRate.csv')
head(fed_funds_data)
# The Dimensions
dim(fed_funds_data)
# The Column Names
colnames(fed_funds_data)
```
### Briefly describe the data
The data consists of the Fed Funds Rate and it has 904 rows and 10 columns. The columns include Federal Funds Target rate, Upper and Lower Target, Real GDP, Unemployment and Inflation rate. There also seems to be a lot of NA values. This maybe since the data would not have been available during those years.
## Tidy Data (as needed)
```{r}
print("Lets see the NA counts by columns")
print("Year")
sum(is.na(fed_funds_data$Year))
print("Month")
sum(is.na(fed_funds_data$Month))
print("Day")
sum(is.na(fed_funds_data$Day))
print("Federal.Funds.Target.Rate")
sum(is.na(fed_funds_data$`Federal.Funds.Target.Rate`))
print("Federal.Funds.Upper.Target")
sum(is.na(fed_funds_data$`Federal.Funds.Upper.Target`))
print("Federal.Funds.Lower.Target")
sum(is.na(fed_funds_data$`Federal.Funds.Lower.Target`))
print("Effective.Federal.Funds.Rate")
sum(is.na(fed_funds_data$`Effective.Federal.Funds.Rate`))
print("Real.GDP..Percent.Change.")
sum(is.na(fed_funds_data$`Real.GDP..Percent.Change.`))
print("Unemployment.Rate")
sum(is.na(fed_funds_data$`Unemployment.Rate`))
print("Inflation.Rate")
sum(is.na(fed_funds_data$`Inflation.Rate`))
```
Seems like there are a lot of NA values for Real.GDP..Percent.Change. column.
But since we are going to use date and those columns are 0, we can go ahead without tidying.
## Identify variables that need to be mutated
We can reduce the date variables of Year, Month and Day and combine them for date based analysis. This can then be reordered.
We will then do analysis of the data and try to extract the date vise Unemployment vs Inflation Rate to see the correlation.
```{r}
fed_funds_data$Date <- ymd(paste(fed_funds_data$Year, fed_funds_data$Month, fed_funds_data$Day, sep = "-"))
summary(fed_funds_data$Date)
summarizedData <- fed_funds_data %>%
group_by(Year) %>%
summarize(MeanOfTargetRate = mean(`Federal.Funds.Target.Rate`, na.rm=TRUE),
MeanOfUpperTarget = mean(`Federal.Funds.Upper.Target`, na.rm = TRUE),
MeanOfLowerTarget = mean(`Federal.Funds.Lower.Target`, na.rm = TRUE))
print(summarizedData, n=100)
dateVsUnemploymentRateInfaltionRate <- fed_funds_data %>%
select(Date, Unemployment.Rate, Inflation.Rate)
dateVsUnemploymentRateInfaltionRate
```