first.var <- 280
second.var <- 41.5
first.var * second.var[1] 11620
Finding Data
First things first: Make a new project in RStudio, and be sure to place it somewhere where you can easily find it (e.g., Documents, Desktop). Then download this file (the .qmd file) from the syllabus website and place it in the folder associated with that project. Then open this file in RStudio and follow along.
I encourage you to work with/talk to others throughout this tutorial, especially during times where I have you code on your own and use AI. When you code, think about the SPARCK framework:
S: Set up (What is your end goal?)
P: Pseudocode (What are the steps?)
A: AI (What are your AI prompts?)
R: Run (Run it!)
C: Check (Did your code work?)
K: Knowledge (What does your code mean?)
There will also be several instances where I will have you go through the full SPARCK framework explicitly.
There are different “types” of data that R knows how to handle. Each is encoded in a slightly different way, and can have different things done to it.
Numeric data encompasses any (real) number. Positive, negative, integer, decimal, all fine. You can do your usual math on numeric data.
The basic arithmetic operators are specified as:
+ addition- subtraction* multiplication/ division^ exponent() parenthesesCreate two numeric objects (variables) and multiply them together.
first.var <- 280
second.var <- 41.5
first.var * second.var[1] 11620
This is letter/word-based data. A piece of character data is called a string.
R understands that this data is made up of text, and treats it in a special way. In order to indicate to R that your data is a string, you need to enclose it in quotation marks. You can do either single or double quotes, as long as it’s the same on either side.
Create a character object of your favorite fruit and display it. Then make all of the letters uppercase and display that. Then display the number of characters in your object.
favefruit <- "passionfruit"
favefruit[1] "passionfruit"
toupper(favefruit)[1] "PASSIONFRUIT"
nchar(favefruit)[1] 12
What functions did you use? What did they do?
Answer: I used toupper() which made all of the letters uppercase, and I used nchar() which told me how many letters were in my fruit string.
Most of the time, when you want to do things in R, you want to do them in some conditions but not others.
Relational operators are the first key to making this happen. These are essentially inequality operators like the ones you would encounter in algebra.
The following is a relational statement. This is a command involving a relational operator that returns TRUE or FALSE based on whether the statement is true or false.
2 > 1[1] TRUE
Here are the relational operators:
> (greater than)< (less than)>= (greater than or equal to)<= (less than or equal to)== (is equal to–NOTE that it is two equals signs, one equals sign does something different)!= (is not equal to)%in% (is contained by; this is useful when you need to see whether the element on the left matches any of a vector of elements on the right)Create two statements using == and two using !=. For each one, one output should be TRUE and one should be FALSE.
5 == 5[1] TRUE
5 != 5[1] FALSE
7 == 10[1] FALSE
7 != 10[1] TRUE
The %in% statement is a little less intuitive than the others. Create a character vector of your four favorite fruits and write an %in% statement that outputs FALSE. Let’s go through the full SPARCK framework here.
S: Output FALSE
P: Create a character vector and save it to an object. Use %in% with something that isn’t in that vector
A: I need you to create a vector in R with these items: passionfruit, mango, apple, plum. Then save it to an object. Then use %in% to see if “peach” is present in the vector.
R:
fruits <- c('passionfruit','mango','apple','plum')
fruits[1] "passionfruit" "mango" "apple" "plum"
'peach' %in% fruits[1] FALSE
C: Peach outputs to FALSE so I know it’s not in the vector. And when I type fruits it shows my vector correctly.
K: First I used c() to make a vector of fruits. Then I used %in% to test if "peach" was in the vector.
Relational statements will get you a long way. Sometimes, though, you need to know whether groups of conditions are true or false. You can combine the TRUEs and FALSEs of relational statements using Boolean logical operators.
These are the core Boolean operators you’ll need in most cases:
! (NOT operator; this returns the opposite of whatever follows it)& (AND operator; this returns TRUE if the statements on both sides are true)| (Pipe, or shift-backslash–OR operator; this returns TRUE if at least one of the statements on either side is true)For example:
1 == 1 & 1 == 2[1] FALSE
Create two statements using & and two using |. For each one, one output should be TRUE and one should be FALSE.
1 == 1 & 2 == 2[1] TRUE
1 == 1 & 4 == 5[1] FALSE
5 == 5 | 3 != 3[1] TRUE
7 != 7 | 4 == 6[1] FALSE
In the last tutorial, we used a dataset that is built into R. More often, we’re going to be reading in external datasets. Datasets can be retrieved from many different places:
Most governments (cities, states, counties, etc.) have a central repository of data related to government activities
Many non-governmental organizations collect and distribute data related to their work
Scientific research studies increasingly make the data associated with their study publicly accessible.
Before we can actually get started looking at external data in R, we need to understand how R interacts with files on your computer. Any data that gets loaded in or saved out is saved on your computer proper, and you can access all of these files through R.
Every R session has a working directory, or a “home base” folder. Essentially, this is the folder that R is “in”. R is not actually installed in this folder, mind you! The working directory is the first folder where R looks for raw data files to load in.
Type the function getwd() in the console to figure out what our current working directory is.
getwd()If you run this command on your own computer, you’ll get a different folder. And that’s okay! Our folder structures on our computers are all different. What you’re looking at is a file path.
Every single file and folder on your computer has an address. You can navigate these paths in your computer’s built-in file browser, but in order for R to be able to access these files, you have to tell R the address.
You can think of your computer’s main drive as a building, with only one front door, and a series of rooms (folders), which may contain stuff (files) or doors leading to more rooms (sub-folders). You can walk through any series of connected doors to get to the room you’re looking for. A file path is a set of directions of which rooms to walk through to get to a particular room (folder) or object (file) in a room.
There are two ways of specifying file paths: absolute and relative.
An absolute file path is a file’s full address on your computer. An absolute path tells you how to get to a file starting from the root folder, which is essentially the one invisible giant folder holding literally everything saved on your computer. In your computer-building, the root folder is the front door.
If you give the directions to a room in your computer-building by starting at the front entrance, your computer will always be able to follow those directions correctly by “teleporting” to the front entrance and then following the directions to get to the room of interest.
The way you specify that a file path starts from the root folder (the front entrance to your computer) differs depending on the operating system.
Meanwhile, relative file paths don’t involve any sort of teleportation. Relative file paths are directions that assume you’re starting in the current working directory (remember from earlier?).
Relative file paths are shorter to type (because you don’t need to specify all the directions to get from the root folder to the current working directory), but they do depend on what the current working directory is. If your working directory is set to a folder other than what you expect, your computer will not be able to follow the relative path you provide because it will be looking for file/folder names that may not exist in its starting location.
To specify a relative path, you only need to start your path with a file or folder name that exists in your current working directory.
One of the benefits of RStudio Projects is that you can set your working directory ahead of time and put all the files you need (R script, Quarto file, data) in there. This means that you can put external data files in this same folder, and to load them into your R session, you don’t need to worry about “where” on your computer they are located; calling the relative file path will do the trick.
Okay, we’re finally ready to actually read in some data. For today’s tutorial, we’re going to use a data file from NYC Open Data on the homeless shelter population. Go to NYC Open Data, search “DHS Daily Report,” go to the dataset, and click Export. Then put the downloaded file in the same folder that you put this .qmd file.
This is a dataset that reports the number of people in NYC homeless shelters every day from 2021 until the present. The data is broken down by different categories - adults, families, children, etc. You can learn more about the dataset on the dataset page.
Use the read_csv() function to save this data to an object in R. Make sure you’re using read_csv(), which is from the tidyverse. Don’t use read.csv().
The downloaded file’s name includes the date you downloaded it, so yours will probably be different from what’s in this answer key.
library(tidyverse)Warning: package 'ggplot2' was built under R version 4.4.3
Warning: package 'tidyr' was built under R version 4.4.3
Warning: package 'purrr' was built under R version 4.4.3
Warning: package 'dplyr' was built under R version 4.4.3
-- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
v dplyr 1.2.0 v readr 2.1.5
v forcats 1.0.0 v stringr 1.5.1
v ggplot2 4.0.2 v tibble 3.2.1
v lubridate 1.9.4 v tidyr 1.3.2
v purrr 1.2.1
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
dhs <- read_csv('DHS_Daily_Report_20260922.csv')Rows: 2030 Columns: 13
-- Column specification --------------------------------------------------------
Delimiter: ","
chr (1): Date of Census
dbl (12): Total Adults in Shelter, Total Children in Shelter, Total Individu...
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
How do you know that you did this properly?
Answer: I can see dhs in my environment
You can give the object any name you like. I’m going to call it dhs, for “Department of Homeless Services,” so that’s how I’ll be referring to it moving forward.
You’ll now see an object called dhs (or whatever you called yours) in your environment (top right window). This is a dataframe, and it contains all of your data. You can click on it to open it up as a tab in the editor window.
This is the data type where it happens! Imagine your usual rectangular spreadsheet, where each column of the spreadsheet contains a meaningful category of information (e.g. subject ID, age, gender, race, task performance, etc.), and each row contains one observation of information (one subject, or one observation). A dataframe is basically that.
A dataframe is a special rectangular data structure in R. Each column contains all the observations of a particular meaningful grouping. Each row contains one complete observation from all the columns. Each observation can be a subject, a trial, a group, whatever–any one meaningful something.
Notice that dataframes can be read in from CSV files. These files can be opened in other programs like Microsoft Excel, where you can see that they look like any garden-variety spreadsheet.
Before diving into the dataset, look at it in the Editor window and make sure you understand what data it contains.
There are a number of different functions you might want to use right off the bat to get to know your data. These include:
names(): Display all of the column names.
head(): Display the first few rows of your data.
summary(): Display some basic summary stats of the spread of your numeric data.
Play around with these functions below.
names(dhs) [1] "Date of Census"
[2] "Total Adults in Shelter"
[3] "Total Children in Shelter"
[4] "Total Individuals in Shelter"
[5] "Single Adult Men in Shelter"
[6] "Single Adult Women in Shelter"
[7] "Total Single Adults in Shelter"
[8] "Families with Children in Shelter"
[9] "Adults in Families with Children in Shelter"
[10] "Children in Families with Children in Shelter"
[11] "Total Individuals in Families with Children in Shelter"
[12] "Adult Families in Shelter"
[13] "Individuals in Adult Families in Shelter"
head(dhs)summary(dhs) Date of Census Total Adults in Shelter Total Children in Shelter
Length:2030 Min. :30312 Min. :14274
Class :character 1st Qu.:34505 1st Qu.:16664
Mode :character Median :53660 Median :28402
Mean :47205 Mean :25606
3rd Qu.:54554 3rd Qu.:31723
Max. :56436 Max. :33468
Total Individuals in Shelter Single Adult Men in Shelter
Min. :44586 Min. :11971
1st Qu.:51089 1st Qu.:13666
Median :83274 Median :15726
Mean :72811 Mean :15430
3rd Qu.:86109 3rd Qu.:16770
Max. :89558 Max. :19097
Single Adult Women in Shelter Total Single Adults in Shelter
Min. :3801 Min. :15985
1st Qu.:4344 1st Qu.:18032
Median :4982 Median :20603
Mean :5197 Mean :20627
3rd Qu.:5734 3rd Qu.:22394
Max. :7565 Max. :26662
Families with Children in Shelter Adults in Families with Children in Shelter
Min. : 8180 Min. :10759
1st Qu.: 9600 1st Qu.:13112
Median :16544 Median :25037
Mean :14886 Mean :22173
3rd Qu.:18314 3rd Qu.:28291
Max. :19641 Max. :30681
Children in Families with Children in Shelter
Min. :14274
1st Qu.:16664
Median :28402
Mean :25606
3rd Qu.:31723
Max. :33468
Total Individuals in Families with Children in Shelter
Min. :25039
1st Qu.:29481
Median :53506
Mean :47780
3rd Qu.:59806
Max. :64112
Adult Families in Shelter Individuals in Adult Families in Shelter
Min. :1385 Min. :2904
1st Qu.:1816 1st Qu.:3821
Median :2145 Median :4587
Mean :2062 Mean :4405
3rd Qu.:2275 3rd Qu.:4898
Max. :3101 Max. :6569
Sometimes you might want to access one specific column of a data frame, rather than the whole thing.
We use a special syntax to do this: the dollar sign $.
$ tells R when a variable name, in this case a column name, is a sub-variable of a larger variable, in this case a data frame.
So let’s say you wanted to display just the total number of children in shelters. To do so, you would type the following:
dhs$`Total Children in Shelter` [1] 16746 16746 16720 16720 16766 16794 16809 16720 16608 16617 16618 16550
[13] 16582 16546 16527 16484 16485 16498 16487 16467 16491 16422 16368 16342
[25] 16311 16261 16269 16267 16214 16227 16169 16178 16180 16161 16187 16145
[37] 16044 16031 16049 16015 16053 16050 15987 15992 16017 16003 15986 15947
[49] 15924 15911 15819 15883 15869 15875 15847 15822 15796 15789 15788 15735
[61] 15716 15711 15688 15609 15631 15629 15587 15606 15630 15619 15504 15458
[73] 15476 15515 15496 15536 15515 15456 15418 15346 15376 15375 15378 15341
[85] 15330 15312 15326 15372 15365 15347 15362 15341 15267 15256 15307 15270
[97] 15279 15298 15238 15239 15201 15288 15265 15253 15245 15195 15173 15169
[109] 15165 15192 15181 15171 15076 15109 15079 15082 15079 15101 15062 15037
[121] 15090 15058 14563 14519 14545 14563 14528 14549 14536 14500 14526 14525
[133] 14538 14538 14539 14490 14528 14545 14561 14550 14453 14435 14435 14429
[145] 14460 14497 14491 14443 14448 14454 14482 14483 14305 14274 14286 14389
[157] 14484 14507 14481 14473 14491 14486 14541 14527 14499 14512 14504 14522
[169] 14522 14542 14375 14382 14404 14433 14472 14474 14480 14433 14392 14420
[181] 14458 14480 14446 14425 14456 14475 14509 14570 14604 14536 14586 14585
[193] 14616 14617 14659 14650 14572 14581 14617 14623 14641 14654 14707 14653
[205] 14732 14616 14656 14721 14760 14750 14789 14741 14812 14798 14815 14833
[217] 14863 14797 14839 14817 14847 14923 14947 14907 14851 14857 14955 14911
[229] 14938 14972 14949 14900 14906 14930 14937 14961 14976 14973 14865 14886
[241] 14921 14927 14931 14893 14887 14822 14852 14840 14903 14922 14898 14883
[253] 14809 14756 14806 14812 14783 14860 14812 14761 14769 14804 14781 14795
[265] 14775 14728 14769 14691 14745 14788 14790 14726 14714 14713 14727 14760
[277] 14727 14725 14787 14802 14787 14773 14782 14816 14908 14855 14855 14861
[289] 14830 14735 14756 14773 14772 14737 14665 14685 14579 14674 14658 14705
[301] 14659 14576 14574 14612 14601 14596 14659 14663 14589 14508 14581 14613
[313] 14654 14622 14596 14558 14602 14662 14621 14559 14573 14588 14609 14597
[325] 14548 14590 14554 14586 14597 14641 14565 14592 14648 14670 14637 14595
[337] 14583 14506 14586 14591 14592 14608 14634 14533 14532 14578 14476 14530
[349] 14558 14576 14521 14429 14462 14518 14517 14557 14510 14531 14507 14476
[361] 14470 14546 14615 14627 14560 14563 14593 14601 14607 14629 14628 14576
[373] 14511 14533 14500 14571 14537 14546 14544 14535 14561 14604 14613 14646
[385] 14668 14664 14586 14584 14610 14593 14559 14565 14570 14525 14560 14637
[397] 14647 14636 14658 14656 14636 14660 14669 14691 14665 14686 14696 14740
[409] 14679 14604 14592 14582 14574 14574 14643 14678 14702 14748 14762 14765
[421] 14822 14820 14823 14831 14824 14776 14765 14731 14811 14863 14862 14893
[433] 14872 14820 14836 14871 14921 14923 14941 15005 15020 14914 14920 14929
[445] 14947 14910 14931 15008 14948 14977 15041 14993 15029 14981 15023 15069
[457] 14988 15050 15131 15162 15134 15163 15181 15212 15235 15240 15228 15294
[469] 15293 15260 15249 15274 15234 15306 15338 15423 15432 15428 15425 15502
[481] 15546 15518 15593 15585 15608 15630 15685 15742 15782 15835 15877 15841
[493] 15870 15907 16014 16006 16003 15992 15943 15997 16047 16057 16030 16023
[505] 16090 16160 16162 16265 16285 16362 16411 16421 16514 16564 16612 16658
[517] 16680 16765 16729 16753 16806 16827 16834 16852 16909 16933 16949 17031
[529] 17084 17105 17126 17147 17221 17120 17148 17169 17205 17221 17233 17220
[541] 17269 17382 17408 17454 17557 17652 17673 17757 17826 17889 17924 18009
[553] 18004 18064 18024 18237 18289 18366 18449 18491 18493 18559 18654 18733
[565] 18821 18901 19027 19045 19121 19242 19260 19308 19389 19414 19412 19394
[577] 19534 19600 19681 19722 19724 19778 19898 19934 20044 20149 20216 20147
[589] 20118 20297 20346 20442 20505 20517 20554 20544 20591 20585 20635 20629
[601] 20676 20627 20579 20574 20584 20602 20580 20614 20576 20500 20505 20530
[613] 20540 20532 20578 20585 20532 20500 20502 20527 20545 20632 20660 20609
[625] 20647 20728 20786 20836 20829 20855 20794 20880 20801 20881 20875 20898
[637] 20860 20885 20891 20918 20920 21051 21099 21021 21008 21099 21196 21071
[649] 21112 21167 21209 21173 21150 21189 21188 21177 21161 21168 21165 21141
[661] 21262 21295 21361 21397 21449 21565 21550 21592 21640 21740 21792 21813
[673] 21875 21954 22001 22025 22096 22116 22197 22294 22371 22380 22419 22412
[685] 22411 22499 22564 22625 22633 22573 22620 22615 22613 22582 22664 22639
[697] 22751 22732 22766 22805 22850 22886 22953 23037 22973 23040 23033 22881
[709] 22871 22866 22874 22912 22915 22838 22782 22772 22756 22779 22812 22847
[721] 22830 22766 22895 22913 22931 23006 23018 23011 22898 22978 22974 22940
[733] 22969 22957 22966 22961 23011 22988 23047 22984 22936 22943 22948 23022
[745] 23016 23029 23091 23168 23208 23196 23303 23355 23376 23430 23377 23424
[757] 23436 23483 23521 23560 23605 23595 23651 23700 23763 23733 23834 23842
[769] 23907 23944 23942 23893 23935 23978 24054 24072 24175 24206 24258 24366
[781] 24439 24473 24547 24577 24540 24644 24750 24803 24909 24992 25067 25112
[793] 25334 25291 25464 25552 25706 25796 25791 25858 26013 26119 26219 26276
[805] 26261 26257 26413 26604 26574 26828 26938 26917 26967 26971 27010 26991
[817] 26889 26908 26880 26946 26923 26940 27015 26841 26901 26820 26805 26915
[829] 26918 26965 26953 26957 26863 26893 26942 26970 26913 27069 27088 27083
[841] 27150 27131 27260 27329 27281 27395 27455 27430 27575 27560 27635 27654
[853] 27681 27630 27677 27684 27811 27818 27859 27865 27895 27927 28025 28096
[865] 28203 28162 28248 28238 28225 28205 28209 28225 28270 28324 28269 28291
[877] 28312 28290 28318 28333 28366 28392 28398 28462 28466 28552 28582 28623
[889] 28648 28727 28867 28963 28970 28916 29121 29214 29266 29215 29311 29265
[901] 29270 29383 29500 29619 29691 29738 29821 29921 29936 29998 30084 30173
[913] 30244 30287 30387 30415 30505 30468 30518 30670 30700 30812 30858 31034
[925] 30977 31076 31114 31180 31240 31293 31302 31253 31312 31403 31450 31469
[937] 31508 31565 31450 31597 31656 31680 31660 31712 31735 31784 31776 31842
[949] 31874 31917 32051 31999 32160 32139 32138 32155 32196 32297 32337 32421
[961] 32403 32350 32434 32495 32656 32666 32652 32619 32633 32660 32688 32765
[973] 32833 32881 32855 32864 32866 32874 32900 32895 32948 32938 33008 33034
[985] 33035 33136 33131 33160 33126 33104 33110 33108 33119 33103 33105 33097
[997] 33124 33182 33150 33156 33079 33042 33008 33013 33033 33027 33114 33147
[1009] 33135 33048 33055 33037 33057 33117 33139 33069 33072 33084 33034 33015
[1021] 33072 33089 33097 33076 33062 33040 32959 32947 32929 32929 32885 32988
[1033] 32927 32970 33086 33152 33243 33220 33183 33155 33179 33194 33253 33303
[1045] 33380 33382 33404 33413 33348 33431 33387 33379 33348 33341 33347 33330
[1057] 33333 33362 33342 33355 33342 33328 33323 33324 33316 33288 33212 33367
[1069] 33373 33403 33341 33303 33307 33251 33184 33215 33152 33156 33075 33063
[1081] 33046 33010 32988 32935 32973 32932 32922 32890 32829 32802 32806 32802
[1093] 32724 32684 32691 32635 32650 32623 32661 32635 32592 32521 32475 32504
[1105] 32399 32435 32425 32335 32347 32338 32375 32355 32394 32216 32166 32143
[1117] 32154 32119 32056 32085 32022 31940 32016 32055 31993 32005 32056 31980
[1129] 31964 31986 32026 32086 32040 32063 32012 31992 32000 32018 31983 31976
[1141] 32007 31934 32452 32494 32537 32463 32373 32386 32375 32382 32435 32431
[1153] 32424 32493 32521 32513 32530 32544 32634 32639 32699 32732 32723 32715
[1165] 32754 32744 32674 32683 32715 32634 32647 32737 32676 32604 32519 32555
[1177] 32576 32612 32578 32575 32569 32583 32605 32601 32552 32560 32570 32587
[1189] 32578 32570 32605 32567 32662 32667 32643 32635 32665 32707 32718 32666
[1201] 32711 32728 32746 32783 32769 32754 32853 32856 32849 32885 32903 32932
[1213] 32987 32959 32955 32979 32995 33065 33052 33040 32920 32938 32900 32897
[1225] 32940 32968 32978 32929 32969 32949 32961 32962 32977 33015 32978 33023
[1237] 33007 33036 32996 32930 32957 32980 33021 33013 33034 33088 33101 33141
[1249] 33156 33140 33137 33136 33168 33194 33226 33244 33257 33248 33268 33280
[1261] 33243 33220 33291 33323 33281 33210 33189 33164 33223 33273 33255 33277
[1273] 33330 33305 33274 33253 33320 33323 33391 33400 33463 33468 33426 33376
[1285] 33398 33290 33269 33347 33250 33233 33238 33200 33132 33129 33133 33121
[1297] 33133 33113 33125 33086 33127 33094 33079 33088 33135 33077 33105 33156
[1309] 33186 33154 33124 33154 33069 33076 32844 32875 32986 33003 33037 33022
[1321] 33040 33013 32996 33015 33017 32958 32901 32835 32834 32833 32783 32783
[1333] 32781 32778 32769 32821 32844 32779 32765 32767 32784 32806 32714 32703
[1345] 32683 32727 32819 32820 32789 32868 32905 32872 32883 32945 32966 32963
[1357] 32955 33004 32912 32930 32901 32828 32813 32860 32729 32727 32766 32877
[1369] 32907 32854 32748 32791 32735 32788 32781 32756 32743 32601 32691 32624
[1381] 32623 32649 32537 32499 32523 32616 32607 32540 32561 32507 32476 32455
[1393] 32548 32609 32574 32561 32534 32484 32499 32496 32326 32405 32473 32447
[1405] 32441 32485 32525 32501 32582 32596 32599 32595 32546 32566 32474 32538
[1417] 32501 32488 32451 32482 32472 32507 32472 32313 32257 32237 32253 32231
[1429] 32216 32208 32174 32098 32019 31962 31967 31866 31681 31716 31659 31550
[1441] 31518 31515 31430 31396 31441 31357 31360 31343 31304 31305 31385 31341
[1453] 31280 31217 31246 31263 31295 31342 31367 31360 31285 31339 31350 31288
[1465] 31228 31135 31164 31244 31247 31270 31234 31201 31219 31201 31227 31310
[1477] 31315 31350 31342 31347 31326 31363 31355 31394 31349 31309 31278 31277
[1489] 31305 31324 31351 31297 31264 31294 31273 31323 31348 31404 31379 31409
[1501] 31461 31482 31472 31516 31568 31624 31583 31592 31573 31596 31722 31710
[1513] 31729 31705 31712 31669 31719 31727 31803 31819 31800 31813 31740 31741
[1525] 31721 31781 31760 31663 31707 31684 31696 31680 31711 31727 31640 31628
[1537] 31635 31643 31687 31769 31717 31633 31683 31663 31664 31722 31695 31735
[1549] 31701 31748 31723 31672 31694 31711 31739 31696 31633 31584 31574 31574
[1561] 31629 31576 31529 31533 31519 31450 31482 31488 31439 31395 31410 31403
[1573] 31417 31386 31390 31293 31310 31322 31347 31264 31300 31336 31346 31284
[1585] 31216 31190 31217 31270 31243 31154 31145 31173 31167 31101 31082 31138
[1597] 31149 31086 31108 31106 31098 31088 31114 31029 31042 31038 31015 31007
[1609] 31019 30876 30918 30973 30966 31012 31044 31066 31053 31069 31072 31052
[1621] 31044 31018 31037 31024 31013 31001 30995 31046 30957 31053 31054 30972
[1633] 31024 31105 31097 31157 31192 31151 31156 31092 31084 31102 31122 31105
[1645] 31108 31120 31115 31103 31097 31091 31124 31134 31119 31072 31118 31088
[1657] 31072 31098 31048 31053 30996 31019 31015 30959 31023 31043 30956 30868
[1669] 30926 30945 30953 30978 31023 30992 31034 30978 30951 30971 31005 31013
[1681] 30946 30924 30971 30954 30868 30947 30953 30941 31000 30973 30953 30916
[1693] 30918 30932 30890 30883 30864 30696 30750 30716 30756 30656 30573 30484
[1705] 30470 30403 30390 30369 30290 30398 30311 30347 30418 30462 30429 30435
[1717] 30460 30440 30448 30440 30496 30439 30314 30396 30374 30314 30294 30402
[1729] 30474 30391 30439 30485 30599 30622 30597 30527 30497 30476 30525 30490
[1741] 30574 30639 30643 30522 30490 30557 30643 30681 30716 30707 30668 30588
[1753] 30599 30583 30657 30727 30634 30575 30547 30566 30654 30660 30685 30606
[1765] 30567 30564 30634 30649 30677 30632 30590 30581 30555 30574 30510 30417
[1777] 30483 30460 30551 30448 30378 30442 30407 30499 30489 30468 30492 30489
[1789] 30426 30405 30496 30561 30545 30420 30255 30310 30359 30384 30408 30305
[1801] 30251 30249 30305 30318 30324 30352 30223 30096 30152 30080 30073 30097
[1813] 30157 30098 30100 30000 29970 30040 30068 30102 29981 29879 29864 29881
[1825] 29880 29922 29974 29940 29847 29777 29719 29762 29757 29836 29770 29613
[1837] 29577 29537 29515 29527 29581 29497 29425 29276 29249 29256 29293 29345
[1849] 29260 29064 29007 29073 29072 29134 29109 29141 29008 28952 28966 28971
[1861] 29022 29079 29002 28935 28867 28868 28886 28894 28948 28959 28822 28734
[1873] 28822 28855 28848 28883 28781 28642 28623 28603 28613 28634 28672 28619
[1885] 28483 28397 28479 28520 28544 28613 28611 28381 28302 28354 28436 28469
[1897] 28529 28495 28310 28367 28341 28326 28400 28450 28367 28175 28183 28241
[1909] 28298 28317 28385 28405 28315 28190 28231 28245 28298 28382 28359 28195
[1921] 28174 28224 28256 28221 28271 28277 28089 28044 28173 28180 28223 28237
[1933] 28187 28216 28159 28182 28230 28318 28276 28273 28184 28083 28204 28220
[1945] 28255 28234 28234 28149 28261 28324 28375 28430 28423 28324 28283 28191
[1957] 28234 28339 28363 28289 28289 28203 28200 28193 28235 28238 28165 28183
[1969] 28159 28060 28005 28002 28065 27949 27952 27954 27990 28093 28090 28139
[1981] 28092 28099 28074 28158 28130 28216 28262 28199 28181 28163 28187 28214
[1993] 28210 28253 28249 28229 28143 28096 28112 28138 28155 28107 28131 28174
[2005] 28086 28089 28147 28219 28259 28189 28165 28247 28105 28205 28268 28344
[2017] 28275 28283 28222 28165 28173 28207 28211 28229 28135 28196 28196 28183
[2029] 28262 28252
In this way, we can tell R that `Total Children in Shelter` is not floating around on its own, but is a column in the data frame dhs. If we were to type `Total Children in Shelter` on its own, we’d get an error:
`Total Children in Shelter`Error:
! object 'Total Children in Shelter' not found
You may also notice when typing in RStudio, that if you type dhs$, you’ll suddenly see a little tab-complete selector pop up, listing out the names of all the columns in dhs.
You can either type more to narrow down to the column you want, and then hit Tab to auto-complete the column name, or use the arrow keys to scroll up and down through the column names to select the one you want (and hit Tab to auto-complete in this case as well).
One quirk of this dataset: the column names have spaces in them, which is usually something we want to avoid. In R, we can indicate that the space is part of the column name by wrapping it in the ` symbol.
But that’s kind of annoying. You can rename individual columns using the rename() function. There’s also a package called janitor with a nifty function called clean_names(), which automatically removes spaces and special characters from column names. It’s really useful when downloading external data, since external data can be so messy.
Use clean_names() to clean up the column names in dhs. (Note: You don’t need to upload your data to Gemini to get it to help you, but you’re totally allowed to! And as things become more complicated, it will likely be very helpful for Gemini to know exactly what your data looks like. It cuts down on explanations you need to provide as well.)
SPARCK
S: Make it so my column names don’t have spaces
P: Install janitor. Load it. Use the clean_names() function on dhs.
A: Use clean_names from the janitor package to clean up my column names. My dataframe is called dhs.
R:
install.packages('janitor')library(janitor)
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
dhs <- clean_names(dhs)Warning in FUN(X[[i]], ...): unable to translate '<U+00C4>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00D6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00DC>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E4>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00F6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00FC>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00DF>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00C6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E6>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00D8>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00F8>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00C5>' to native encoding
Warning in FUN(X[[i]], ...): unable to translate '<U+00E5>' to native encoding
C: When I open up the dhs dataframe the column names look different!
K: The clean_names() function cleaned all of my column names
Next week we’re going to get into data cleaning/wrangling, and we’ll learn all sorts of functions from tidyverse that help us clean up our data. For today, we’ll keep it simple and focus on basic mathematical calculations you can do on your data frame columns, just like you can do on any vector.
Calculate the daily mean number of total individuals in shelters across this entire dataset.
mean(dhs$total_individuals_in_shelter)[1] 72811.35
Now calculate the minimum and maximum daily number of single women in shelters.
max(dhs$single_adult_women_in_shelter)[1] 7565
min(dhs$single_adult_women_in_shelter)[1] 3801
Divide the families with children variable by 1,000.
dhs$families_with_children_in_shelter/1000 [1] 9.593 9.590 9.579 9.578 9.598 9.612 9.624 9.571 9.508 9.514
[11] 9.531 9.476 9.491 9.472 9.462 9.440 9.434 9.438 9.430 9.420
[21] 9.440 9.398 9.375 9.360 9.352 9.331 9.340 9.343 9.313 9.319
[31] 9.300 9.292 9.285 9.280 9.299 9.257 9.205 9.208 9.220 9.206
[41] 9.218 9.210 9.184 9.185 9.197 9.197 9.191 9.167 9.150 9.140
[51] 9.095 9.112 9.106 9.108 9.106 9.095 9.075 9.076 9.080 9.061
[61] 9.054 9.042 9.026 9.000 8.997 9.039 8.985 8.999 8.994 8.981
[71] 8.920 8.894 8.916 8.930 8.934 8.957 8.937 8.908 8.905 8.867
[81] 8.875 8.865 8.859 8.831 8.824 8.833 8.838 8.845 8.852 8.858
[91] 8.879 8.872 8.835 8.821 8.842 8.819 8.830 8.847 8.800 8.798
[101] 8.776 8.817 8.808 8.802 8.800 8.762 8.759 8.768 8.755 8.777
[111] 8.775 8.767 8.704 8.721 8.703 8.709 8.709 8.716 8.685 8.658
[121] 8.691 8.674 8.327 8.303 8.324 8.333 8.314 8.324 8.303 8.278
[131] 8.291 8.290 8.307 8.282 8.282 8.269 8.305 8.310 8.325 8.316
[141] 8.273 8.262 8.257 8.260 8.287 8.318 8.306 8.267 8.271 8.282
[151] 8.299 8.296 8.192 8.180 8.181 8.233 8.292 8.309 8.302 8.295
[161] 8.309 8.312 8.335 8.317 8.304 8.328 8.330 8.342 8.347 8.362
[171] 8.259 8.268 8.278 8.307 8.330 8.335 8.326 8.299 8.272 8.289
[181] 8.315 8.321 8.302 8.293 8.313 8.314 8.329 8.371 8.388 8.354
[191] 8.378 8.374 8.387 8.400 8.416 8.411 8.341 8.353 8.378 8.378
[201] 8.400 8.415 8.452 8.412 8.460 8.383 8.406 8.436 8.466 8.471
[211] 8.495 8.478 8.503 8.500 8.513 8.532 8.545 8.516 8.540 8.537
[221] 8.539 8.586 8.603 8.585 8.547 8.554 8.614 8.590 8.604 8.615
[231] 8.613 8.592 8.585 8.604 8.611 8.624 8.639 8.640 8.578 8.579
[241] 8.599 8.599 8.616 8.596 8.591 8.541 8.559 8.562 8.582 8.592
[251] 8.558 8.554 8.524 8.493 8.523 8.537 8.539 8.569 8.541 8.521
[261] 8.523 8.554 8.545 8.545 8.547 8.511 8.528 8.481 8.513 8.544
[271] 8.550 8.514 8.500 8.494 8.498 8.498 8.496 8.484 8.512 8.516
[281] 8.498 8.500 8.507 8.529 8.581 8.560 8.559 8.553 8.547 8.501
[291] 8.513 8.526 8.520 8.511 8.463 8.480 8.407 8.467 8.460 8.482
[301] 8.460 8.413 8.384 8.413 8.417 8.430 8.455 8.459 8.421 8.380
[311] 8.416 8.435 8.463 8.455 8.434 8.417 8.437 8.467 8.456 8.421
[321] 8.438 8.447 8.460 8.455 8.418 8.446 8.414 8.440 8.445 8.465
[331] 8.426 8.431 8.480 8.487 8.474 8.440 8.442 8.409 8.448 8.458
[341] 8.450 8.455 8.465 8.406 8.401 8.424 8.371 8.408 8.415 8.432
[351] 8.400 8.338 8.359 8.387 8.401 8.425 8.386 8.393 8.394 8.389
[361] 8.390 8.425 8.459 8.464 8.433 8.432 8.439 8.440 8.441 8.447
[371] 8.449 8.410 8.394 8.401 8.391 8.435 8.417 8.429 8.435 8.428
[381] 8.435 8.448 8.446 8.464 8.477 8.478 8.425 8.428 8.447 8.440
[391] 8.416 8.421 8.428 8.411 8.428 8.462 8.473 8.473 8.490 8.489
[401] 8.475 8.487 8.490 8.509 8.488 8.503 8.494 8.533 8.493 8.449
[411] 8.442 8.428 8.418 8.426 8.467 8.473 8.490 8.517 8.530 8.537
[421] 8.566 8.570 8.582 8.595 8.592 8.569 8.587 8.555 8.582 8.619
[431] 8.614 8.641 8.633 8.601 8.601 8.633 8.668 8.686 8.699 8.733
[441] 8.737 8.683 8.691 8.706 8.714 8.709 8.713 8.758 8.744 8.760
[451] 8.803 8.770 8.791 8.759 8.776 8.802 8.758 8.797 8.841 8.858
[461] 8.846 8.864 8.874 8.889 8.896 8.901 8.886 8.924 8.922 8.909
[471] 8.914 8.924 8.906 8.946 8.961 9.003 9.011 9.004 8.993 9.039
[481] 9.077 9.073 9.121 9.121 9.117 9.136 9.181 9.202 9.217 9.253
[491] 9.278 9.249 9.266 9.294 9.369 9.366 9.365 9.359 9.339 9.370
[501] 9.400 9.415 9.379 9.375 9.404 9.445 9.446 9.520 9.542 9.584
[511] 9.607 9.616 9.659 9.687 9.714 9.753 9.771 9.810 9.790 9.809
[521] 9.852 9.869 9.874 9.897 9.922 9.932 9.941 10.001 10.037 10.044
[531] 10.075 10.084 10.121 10.064 10.095 10.115 10.124 10.144 10.155 10.146
[541] 10.188 10.255 10.253 10.293 10.335 10.376 10.393 10.449 10.485 10.530
[551] 10.548 10.601 10.596 10.639 10.611 10.733 10.757 10.798 10.837 10.871
[561] 10.863 10.907 10.968 11.024 11.078 11.116 11.198 11.216 11.255 11.325
[571] 11.344 11.354 11.416 11.436 11.431 11.432 11.514 11.558 11.605 11.638
[581] 11.636 11.678 11.746 11.765 11.819 11.872 11.910 11.880 11.873 11.960
[591] 11.986 12.046 12.069 12.072 12.098 12.096 12.131 12.130 12.158 12.156
[601] 12.181 12.154 12.115 12.118 12.112 12.118 12.097 12.120 12.094 12.046
[611] 12.048 12.064 12.071 12.057 12.092 12.106 12.082 12.076 12.075 12.096
[621] 12.117 12.157 12.164 12.134 12.147 12.186 12.204 12.224 12.211 12.205
[631] 12.178 12.226 12.170 12.218 12.210 12.223 12.205 12.222 12.220 12.229
[641] 12.221 12.295 12.314 12.285 12.280 12.316 12.356 12.299 12.322 12.342
[651] 12.373 12.360 12.339 12.361 12.360 12.347 12.323 12.328 12.329 12.302
[661] 12.379 12.414 12.439 12.464 12.502 12.569 12.551 12.573 12.584 12.642
[671] 12.687 12.706 12.746 12.796 12.826 12.847 12.889 12.895 12.947 13.004
[681] 13.051 13.048 13.078 13.070 13.052 13.103 13.142 13.186 13.203 13.167
[691] 13.201 13.202 13.211 13.202 13.247 13.232 13.310 13.305 13.327 13.347
[701] 13.367 13.390 13.440 13.502 13.458 13.502 13.499 13.398 13.408 13.407
[711] 13.431 13.449 13.436 13.399 13.372 13.378 13.355 13.375 13.388 13.419
[721] 13.419 13.370 13.446 13.445 13.461 13.501 13.508 13.500 13.441 13.483
[731] 13.485 13.456 13.484 13.486 13.489 13.481 13.518 13.483 13.529 13.518
[741] 13.496 13.502 13.513 13.539 13.554 13.551 13.591 13.618 13.646 13.648
[751] 13.705 13.746 13.761 13.787 13.731 13.763 13.786 13.809 13.845 13.866
[761] 13.890 13.889 13.917 13.948 13.961 13.944 14.009 14.011 14.034 14.072
[771] 14.079 14.025 14.056 14.092 14.130 14.162 14.217 14.238 14.272 14.334
[781] 14.370 14.385 14.426 14.430 14.427 14.475 14.533 14.578 14.647 14.689
[791] 14.733 14.744 14.856 14.836 14.939 15.003 15.100 15.165 15.150 15.185
[801] 15.266 15.339 15.382 15.420 15.421 15.434 15.535 15.648 15.630 15.788
[811] 15.846 15.843 15.874 15.878 15.901 15.885 15.830 15.836 15.815 15.847
[821] 15.840 15.864 15.898 15.794 15.833 15.788 15.774 15.846 15.837 15.869
[831] 15.870 15.881 15.814 15.816 15.861 15.880 15.843 15.926 15.937 15.924
[841] 15.971 15.961 16.029 16.072 16.030 16.101 16.134 16.129 16.194 16.181
[851] 16.228 16.232 16.240 16.204 16.239 16.246 16.306 16.287 16.308 16.329
[861] 16.337 16.369 16.411 16.445 16.505 16.477 16.508 16.491 16.490 16.489
[871] 16.491 16.513 16.527 16.544 16.522 16.544 16.564 16.559 16.587 16.595
[881] 16.635 16.638 16.643 16.671 16.683 16.716 16.739 16.776 16.781 16.820
[891] 16.893 16.929 16.915 16.902 17.026 17.075 17.090 17.078 17.132 17.094
[901] 17.100 17.160 17.219 17.293 17.334 17.365 17.395 17.464 17.465 17.495
[911] 17.549 17.605 17.665 17.693 17.753 17.777 17.816 17.810 17.833 17.937
[921] 17.960 18.020 18.034 18.140 18.112 18.160 18.183 18.232 18.280 18.299
[931] 18.312 18.282 18.318 18.360 18.399 18.416 18.439 18.484 18.413 18.501
[941] 18.542 18.555 18.536 18.565 18.559 18.570 18.578 18.615 18.661 18.684
[951] 18.753 18.730 18.824 18.808 18.834 18.840 18.864 18.909 18.939 19.003
[961] 18.986 18.942 18.995 19.039 19.104 19.113 19.102 19.088 19.091 19.096
[971] 19.114 19.155 19.198 19.222 19.205 19.227 19.217 19.218 19.235 19.243
[981] 19.272 19.265 19.302 19.300 19.292 19.354 19.354 19.381 19.368 19.342
[991] 19.345 19.332 19.352 19.332 19.334 19.336 19.347 19.376 19.365 19.385
[1001] 19.329 19.309 19.301 19.316 19.320 19.331 19.377 19.398 19.389 19.350
[1011] 19.352 19.347 19.348 19.376 19.393 19.363 19.369 19.372 19.358 19.355
[1021] 19.360 19.380 19.392 19.384 19.356 19.340 19.302 19.302 19.304 19.313
[1031] 19.291 19.358 19.316 19.333 19.383 19.423 19.492 19.485 19.472 19.452
[1041] 19.483 19.496 19.546 19.554 19.590 19.602 19.620 19.627 19.596 19.641
[1051] 19.611 19.590 19.579 19.556 19.543 19.518 19.527 19.523 19.524 19.536
[1061] 19.525 19.526 19.523 19.513 19.505 19.489 19.439 19.508 19.506 19.533
[1071] 19.480 19.448 19.461 19.420 19.372 19.398 19.357 19.370 19.322 19.309
[1081] 19.286 19.258 19.243 19.215 19.244 19.221 19.220 19.199 19.165 19.148
[1091] 19.164 19.159 19.106 19.090 19.096 19.080 19.086 19.050 19.070 19.057
[1101] 19.033 18.983 18.961 18.982 18.934 18.941 18.938 18.882 18.877 18.863
[1111] 18.869 18.865 18.892 18.760 18.737 18.735 18.723 18.700 18.673 18.691
[1121] 18.635 18.605 18.638 18.670 18.629 18.638 18.667 18.634 18.619 18.627
[1131] 18.633 18.663 18.639 18.647 18.631 18.600 18.599 18.614 18.594 18.585
[1141] 18.608 18.577 18.847 18.857 18.883 18.838 18.784 18.780 18.775 18.775
[1151] 18.826 18.824 18.809 18.844 18.860 18.865 18.873 18.887 18.941 18.949
[1161] 18.980 18.999 19.002 19.006 19.021 19.028 19.002 18.999 19.036 18.970
[1171] 18.987 19.030 18.991 18.962 18.914 18.934 18.937 18.942 18.927 18.925
[1181] 18.930 18.942 18.962 18.977 18.957 18.955 18.949 18.943 18.947 18.927
[1191] 18.938 18.927 18.975 18.987 18.976 18.979 19.002 19.028 19.037 18.998
[1201] 19.030 19.045 19.061 19.084 19.078 19.058 19.097 19.106 19.099 19.117
[1211] 19.144 19.170 19.202 19.178 19.192 19.201 19.213 19.249 19.243 19.213
[1221] 19.165 19.178 19.149 19.142 19.174 19.188 19.182 19.153 19.185 19.180
[1231] 19.186 19.185 19.191 19.224 19.209 19.217 19.226 19.247 19.217 19.184
[1241] 19.225 19.242 19.274 19.262 19.281 19.307 19.318 19.324 19.334 19.325
[1251] 19.339 19.358 19.379 19.407 19.423 19.420 19.431 19.424 19.441 19.445
[1261] 19.411 19.378 19.421 19.439 19.402 19.382 19.365 19.351 19.389 19.408
[1271] 19.409 19.411 19.437 19.433 19.397 19.412 19.442 19.442 19.482 19.483
[1281] 19.514 19.527 19.505 19.482 19.483 19.432 19.446 19.488 19.440 19.404
[1291] 19.407 19.403 19.357 19.351 19.364 19.342 19.342 19.329 19.330 19.305
[1301] 19.334 19.319 19.306 19.307 19.341 19.316 19.316 19.343 19.369 19.354
[1311] 19.344 19.354 19.287 19.304 19.162 19.186 19.235 19.245 19.266 19.248
[1321] 19.244 19.239 19.227 19.249 19.246 19.194 19.167 19.134 19.129 19.132
[1331] 19.114 19.103 19.114 19.100 19.095 19.122 19.116 19.073 19.076 19.086
[1341] 19.096 19.108 19.051 19.051 19.047 19.060 19.102 19.108 19.096 19.140
[1351] 19.147 19.127 19.140 19.185 19.195 19.176 19.157 19.193 19.150 19.164
[1361] 19.164 19.139 19.131 19.151 19.091 19.102 19.126 19.174 19.202 19.176
[1371] 19.123 19.158 19.134 19.160 19.152 19.142 19.121 19.051 19.094 19.037
[1381] 19.053 19.064 19.015 18.984 18.998 19.052 19.049 18.982 19.012 18.989
[1391] 18.979 18.972 19.021 19.044 19.024 19.028 19.011 18.979 18.968 18.956
[1401] 18.831 18.863 18.907 18.896 18.883 18.905 18.927 18.896 18.932 18.940
[1411] 18.960 18.950 18.920 18.932 18.875 18.924 18.911 18.902 18.869 18.878
[1421] 18.864 18.897 18.876 18.783 18.747 18.745 18.736 18.711 18.719 18.711
[1431] 18.698 18.656 18.607 18.573 18.565 18.509 18.398 18.396 18.346 18.283
[1441] 18.279 18.278 18.237 18.223 18.250 18.189 18.195 18.182 18.176 18.170
[1451] 18.203 18.172 18.135 18.105 18.121 18.123 18.134 18.160 18.163 18.177
[1461] 18.144 18.176 18.173 18.141 18.125 18.076 18.090 18.131 18.133 18.130
[1471] 18.103 18.093 18.105 18.093 18.086 18.134 18.135 18.148 18.140 18.142
[1481] 18.119 18.138 18.141 18.150 18.129 18.104 18.083 18.077 18.086 18.106
[1491] 18.120 18.090 18.065 18.097 18.073 18.084 18.098 18.119 18.111 18.132
[1501] 18.161 18.181 18.143 18.175 18.205 18.221 18.206 18.208 18.171 18.191
[1511] 18.259 18.253 18.253 18.232 18.247 18.212 18.246 18.244 18.283 18.296
[1521] 18.298 18.310 18.270 18.254 18.248 18.284 18.272 18.226 18.252 18.230
[1531] 18.233 18.219 18.245 18.257 18.217 18.221 18.218 18.233 18.266 18.312
[1541] 18.287 18.245 18.286 18.259 18.263 18.312 18.293 18.306 18.280 18.309
[1551] 18.296 18.281 18.292 18.311 18.315 18.284 18.247 18.222 18.235 18.239
[1561] 18.260 18.232 18.212 18.221 18.207 18.178 18.175 18.174 18.156 18.139
[1571] 18.135 18.141 18.146 18.130 18.127 18.067 18.089 18.089 18.120 18.077
[1581] 18.088 18.116 18.118 18.084 18.055 18.040 18.055 18.090 18.064 18.005
[1591] 18.007 18.032 18.024 17.974 17.977 18.011 18.006 17.968 17.975 17.968
[1601] 17.970 17.979 17.985 17.945 17.965 17.951 17.937 17.929 17.938 17.845
[1611] 17.868 17.899 17.898 17.903 17.923 17.931 17.924 17.923 17.921 17.903
[1621] 17.914 17.893 17.908 17.902 17.896 17.881 17.887 17.898 17.841 17.894
[1631] 17.905 17.849 17.872 17.912 17.904 17.925 17.946 17.923 17.919 17.891
[1641] 17.879 17.892 17.911 17.912 17.904 17.918 17.919 17.917 17.926 17.915
[1651] 17.930 17.926 17.928 17.912 17.942 17.930 17.919 17.931 17.919 17.918
[1661] 17.881 17.889 17.891 17.853 17.903 17.906 17.863 17.833 17.863 17.878
[1671] 17.902 17.916 17.939 17.909 17.933 17.903 17.890 17.888 17.921 17.919
[1681] 17.900 17.873 17.919 17.898 17.858 17.914 17.922 17.908 17.942 17.912
[1691] 17.907 17.891 17.887 17.887 17.876 17.875 17.864 17.773 17.791 17.772
[1701] 17.786 17.740 17.698 17.664 17.652 17.616 17.612 17.602 17.535 17.602
[1711] 17.546 17.552 17.594 17.619 17.598 17.597 17.608 17.596 17.606 17.607
[1721] 17.637 17.590 17.525 17.562 17.555 17.532 17.525 17.595 17.632 17.580
[1731] 17.613 17.624 17.675 17.686 17.672 17.627 17.601 17.590 17.615 17.579
[1741] 17.621 17.662 17.660 17.585 17.581 17.610 17.639 17.671 17.689 17.682
[1751] 17.651 17.609 17.617 17.597 17.649 17.690 17.641 17.605 17.584 17.587
[1761] 17.637 17.630 17.657 17.597 17.579 17.577 17.617 17.624 17.645 17.625
[1771] 17.600 17.591 17.568 17.595 17.557 17.515 17.564 17.563 17.621 17.561
[1781] 17.540 17.553 17.542 17.591 17.575 17.564 17.582 17.573 17.548 17.546
[1791] 17.582 17.622 17.614 17.550 17.456 17.487 17.515 17.530 17.548 17.492
[1801] 17.483 17.479 17.506 17.506 17.501 17.519 17.466 17.396 17.399 17.344
[1811] 17.347 17.369 17.409 17.374 17.384 17.325 17.303 17.354 17.376 17.401
[1821] 17.330 17.265 17.253 17.260 17.255 17.277 17.314 17.297 17.241 17.213
[1831] 17.178 17.202 17.201 17.252 17.221 17.121 17.090 17.076 17.060 17.078
[1841] 17.115 17.066 17.013 16.913 16.900 16.918 16.943 16.971 16.928 16.820
[1851] 16.798 16.846 16.839 16.873 16.847 16.850 16.789 16.755 16.779 16.782
[1861] 16.814 16.850 16.817 16.758 16.721 16.714 16.736 16.753 16.786 16.779
[1871] 16.691 16.619 16.666 16.698 16.711 16.730 16.674 16.578 16.570 16.564
[1881] 16.583 16.591 16.618 16.583 16.502 16.459 16.531 16.557 16.571 16.624
[1891] 16.635 16.512 16.443 16.460 16.502 16.537 16.563 16.551 16.416 16.447
[1901] 16.432 16.423 16.474 16.510 16.446 16.324 16.309 16.343 16.382 16.402
[1911] 16.440 16.461 16.383 16.308 16.345 16.369 16.407 16.452 16.439 16.338
[1921] 16.320 16.350 16.377 16.360 16.394 16.409 16.293 16.260 16.330 16.346
[1931] 16.373 16.378 16.341 16.362 16.319 16.332 16.375 16.421 16.393 16.394
[1941] 16.346 16.282 16.347 16.358 16.385 16.372 16.377 16.319 16.386 16.423
[1951] 16.457 16.494 16.479 16.427 16.378 16.321 16.348 16.404 16.429 16.394
[1961] 16.386 16.350 16.355 16.347 16.384 16.382 16.357 16.363 16.360 16.303
[1971] 16.270 16.281 16.311 16.260 16.249 16.217 16.223 16.295 16.288 16.318
[1981] 16.297 16.302 16.290 16.320 16.330 16.380 16.416 16.378 16.388 16.397
[1991] 16.400 16.421 16.428 16.460 16.466 16.455 16.411 16.384 16.379 16.406
[2001] 16.419 16.402 16.422 16.435 16.380 16.376 16.403 16.446 16.470 16.430
[2011] 16.418 16.473 16.383 16.435 16.481 16.510 16.477 16.500 16.448 16.421
[2021] 16.435 16.450 16.447 16.460 16.396 16.423 16.411 16.411 16.447 16.451
Just like our small vector last week, R “vectorizes” mathematical calculations, meaning it applies them to every value in your vector.
One last thing!
Note that you can only do mathematical calculations on numeric data. You can check if a column is numeric with the class() function. Check the class of the date column.
class(dhs$date_of_census)[1] "character"
You’ll see that it’s a character type. R actually has a special data-type for dates and times. This can prove very useful if you ever want to sort your data by time, extract the year or month from a full date, etc.
Use the mdy() function (from the tidyverse) on the date column to display it in date-time format.
mdy(dhs$date_of_census) [1] "2021-03-01" "2021-03-02" "2021-03-03" "2021-03-04" "2021-03-05"
[6] "2021-03-06" "2021-03-07" "2021-03-08" "2021-03-09" "2021-03-10"
[11] "2021-03-11" "2021-03-12" "2021-03-13" "2021-03-14" "2021-03-15"
[16] "2021-03-16" "2021-03-17" "2021-03-18" "2021-03-19" "2021-03-20"
[21] "2021-03-21" "2021-03-22" "2021-03-23" "2021-03-24" "2021-03-25"
[26] "2021-03-26" "2021-03-27" "2021-03-28" "2021-03-29" "2021-03-30"
[31] "2021-03-31" "2021-04-01" "2021-04-02" "2021-04-03" "2021-04-04"
[36] "2021-04-05" "2021-04-06" "2021-04-07" "2021-04-08" "2021-04-09"
[41] "2021-04-10" "2021-04-11" "2021-04-12" "2021-04-13" "2021-04-14"
[46] "2021-04-15" "2021-04-16" "2021-04-17" "2021-04-18" "2021-04-19"
[51] "2021-04-20" "2021-04-21" "2021-04-22" "2021-04-23" "2021-04-24"
[56] "2021-04-25" "2021-04-26" "2021-04-27" "2021-04-28" "2021-04-29"
[61] "2021-04-30" "2021-05-01" "2021-05-02" "2021-05-03" "2021-05-04"
[66] "2021-05-05" "2021-05-06" "2021-05-07" "2021-05-08" "2021-05-09"
[71] "2021-05-10" "2021-05-11" "2021-05-12" "2021-05-13" "2021-05-14"
[76] "2021-05-15" "2021-05-16" "2021-05-17" "2021-05-18" "2021-05-19"
[81] "2021-05-20" "2021-05-21" "2021-05-22" "2021-05-23" "2021-05-24"
[86] "2021-05-25" "2021-05-26" "2021-05-27" "2021-05-28" "2021-05-29"
[91] "2021-05-30" "2021-05-31" "2021-06-01" "2021-06-02" "2021-06-03"
[96] "2021-06-04" "2021-06-05" "2021-06-06" "2021-06-07" "2021-06-08"
[101] "2021-06-09" "2021-06-10" "2021-06-11" "2021-06-12" "2021-06-13"
[106] "2021-06-14" "2021-06-15" "2021-06-16" "2021-06-17" "2021-06-18"
[111] "2021-06-19" "2021-06-20" "2021-06-21" "2021-06-22" "2021-06-23"
[116] "2021-06-24" "2021-06-25" "2021-06-26" "2021-06-27" "2021-06-28"
[121] "2021-06-29" "2021-06-30" "2021-07-01" "2021-07-02" "2021-07-03"
[126] "2021-07-04" "2021-07-05" "2021-07-06" "2021-07-07" "2021-07-08"
[131] "2021-07-09" "2021-07-10" "2021-07-11" "2021-07-12" "2021-07-13"
[136] "2021-07-14" "2021-07-15" "2021-07-16" "2021-07-17" "2021-07-18"
[141] "2021-07-19" "2021-07-20" "2021-07-21" "2021-07-22" "2021-07-23"
[146] "2021-07-24" "2021-07-25" "2021-07-26" "2021-07-27" "2021-07-28"
[151] "2021-07-29" "2021-07-30" "2021-07-31" "2021-08-01" "2021-08-02"
[156] "2021-08-03" "2021-08-04" "2021-08-05" "2021-08-06" "2021-08-07"
[161] "2021-08-08" "2021-08-09" "2021-08-10" "2021-08-11" "2021-08-12"
[166] "2021-08-13" "2021-08-14" "2021-08-15" "2021-08-16" "2021-08-17"
[171] "2021-08-18" "2021-08-19" "2021-08-20" "2021-08-21" "2021-08-22"
[176] "2021-08-23" "2021-08-24" "2021-08-25" "2021-08-26" "2021-08-27"
[181] "2021-08-28" "2021-08-29" "2021-08-30" "2021-08-31" "2021-09-01"
[186] "2021-09-02" "2021-09-03" "2021-09-04" "2021-09-05" "2021-09-06"
[191] "2021-09-07" "2021-09-08" "2021-09-09" "2021-09-10" "2021-09-11"
[196] "2021-09-12" "2021-09-13" "2021-09-14" "2021-09-15" "2021-09-16"
[201] "2021-09-17" "2021-09-18" "2021-09-19" "2021-09-20" "2021-09-21"
[206] "2021-09-22" "2021-09-23" "2021-09-24" "2021-09-25" "2021-09-26"
[211] "2021-09-27" "2021-09-28" "2021-09-29" "2021-09-30" "2021-10-01"
[216] "2021-10-02" "2021-10-03" "2021-10-04" "2021-10-05" "2021-10-06"
[221] "2021-10-07" "2021-10-08" "2021-10-09" "2021-10-10" "2021-10-11"
[226] "2021-10-12" "2021-10-13" "2021-10-14" "2021-10-15" "2021-10-16"
[231] "2021-10-17" "2021-10-18" "2021-10-19" "2021-10-20" "2021-10-21"
[236] "2021-10-22" "2021-10-23" "2021-10-24" "2021-10-25" "2021-10-26"
[241] "2021-10-27" "2021-10-28" "2021-10-29" "2021-10-30" "2021-10-31"
[246] "2021-11-01" "2021-11-02" "2021-11-03" "2021-11-04" "2021-11-05"
[251] "2021-11-06" "2021-11-07" "2021-11-08" "2021-11-09" "2021-11-10"
[256] "2021-11-11" "2021-11-12" "2021-11-13" "2021-11-14" "2021-11-15"
[261] "2021-11-16" "2021-11-17" "2021-11-18" "2021-11-19" "2021-11-20"
[266] "2021-11-21" "2021-11-22" "2021-11-23" "2021-11-24" "2021-11-25"
[271] "2021-11-26" "2021-11-27" "2021-11-28" "2021-11-29" "2021-11-30"
[276] "2021-12-01" "2021-12-02" "2021-12-03" "2021-12-04" "2021-12-05"
[281] "2021-12-06" "2021-12-07" "2021-12-08" "2021-12-09" "2021-12-10"
[286] "2021-12-11" "2021-12-12" "2021-12-13" "2021-12-14" "2021-12-15"
[291] "2021-12-16" "2021-12-17" "2021-12-18" "2021-12-19" "2021-12-20"
[296] "2021-12-21" "2021-12-22" "2021-12-23" "2021-12-24" "2021-12-25"
[301] "2021-12-26" "2021-12-27" "2021-12-28" "2021-12-29" "2021-12-30"
[306] "2021-12-31" "2022-01-01" "2022-01-02" "2022-01-03" "2022-01-04"
[311] "2022-01-05" "2022-01-06" "2022-01-07" "2022-01-08" "2022-01-09"
[316] "2022-01-10" "2022-01-11" "2022-01-12" "2022-01-13" "2022-01-14"
[321] "2022-01-15" "2022-01-16" "2022-01-17" "2022-01-18" "2022-01-19"
[326] "2022-01-20" "2022-01-21" "2022-01-22" "2022-01-23" "2022-01-24"
[331] "2022-01-25" "2022-01-26" "2022-01-27" "2022-01-28" "2022-01-29"
[336] "2022-01-30" "2022-01-31" "2022-02-01" "2022-02-02" "2022-02-03"
[341] "2022-02-04" "2022-02-05" "2022-02-06" "2022-02-07" "2022-02-08"
[346] "2022-02-09" "2022-02-10" "2022-02-11" "2022-02-12" "2022-02-13"
[351] "2022-02-14" "2022-02-15" "2022-02-16" "2022-02-17" "2022-02-18"
[356] "2022-02-19" "2022-02-20" "2022-02-21" "2022-02-22" "2022-02-23"
[361] "2022-02-24" "2022-02-25" "2022-02-26" "2022-02-27" "2022-02-28"
[366] "2022-03-01" "2022-03-02" "2022-03-03" "2022-03-04" "2022-03-05"
[371] "2022-03-06" "2022-03-07" "2022-03-08" "2022-03-09" "2022-03-10"
[376] "2022-03-11" "2022-03-12" "2022-03-13" "2022-03-14" "2022-03-15"
[381] "2022-03-16" "2022-03-17" "2022-03-18" "2022-03-19" "2022-03-20"
[386] "2022-03-21" "2022-03-22" "2022-03-23" "2022-03-24" "2022-03-25"
[391] "2022-03-26" "2022-03-27" "2022-03-28" "2022-03-29" "2022-03-30"
[396] "2022-03-31" "2022-04-01" "2022-04-02" "2022-04-03" "2022-04-04"
[401] "2022-04-05" "2022-04-06" "2022-04-07" "2022-04-08" "2022-04-09"
[406] "2022-04-10" "2022-04-11" "2022-04-12" "2022-04-13" "2022-04-14"
[411] "2022-04-15" "2022-04-16" "2022-04-17" "2022-04-18" "2022-04-19"
[416] "2022-04-20" "2022-04-21" "2022-04-22" "2022-04-23" "2022-04-24"
[421] "2022-04-25" "2022-04-26" "2022-04-27" "2022-04-28" "2022-04-29"
[426] "2022-04-30" "2022-05-01" "2022-05-02" "2022-05-03" "2022-05-04"
[431] "2022-05-05" "2022-05-06" "2022-05-07" "2022-05-08" "2022-05-09"
[436] "2022-05-10" "2022-05-11" "2022-05-12" "2022-05-13" "2022-05-14"
[441] "2022-05-15" "2022-05-16" "2022-05-17" "2022-05-18" "2022-05-19"
[446] "2022-05-20" "2022-05-21" "2022-05-22" "2022-05-23" "2022-05-24"
[451] "2022-05-25" "2022-05-26" "2022-05-27" "2022-05-28" "2022-05-29"
[456] "2022-05-30" "2022-05-31" "2022-06-01" "2022-06-02" "2022-06-03"
[461] "2022-06-04" "2022-06-05" "2022-06-06" "2022-06-07" "2022-06-08"
[466] "2022-06-09" "2022-06-10" "2022-06-11" "2022-06-12" "2022-06-13"
[471] "2022-06-14" "2022-06-15" "2022-06-16" "2022-06-17" "2022-06-18"
[476] "2022-06-19" "2022-06-20" "2022-06-21" "2022-06-22" "2022-06-23"
[481] "2022-06-24" "2022-06-25" "2022-06-26" "2022-06-27" "2022-06-28"
[486] "2022-06-29" "2022-06-30" "2022-07-01" "2022-07-02" "2022-07-03"
[491] "2022-07-04" "2022-07-05" "2022-07-06" "2022-07-07" "2022-07-08"
[496] "2022-07-09" "2022-07-10" "2022-07-11" "2022-07-12" "2022-07-13"
[501] "2022-07-14" "2022-07-15" "2022-07-16" "2022-07-17" "2022-07-18"
[506] "2022-07-19" "2022-07-20" "2022-07-21" "2022-07-22" "2022-07-23"
[511] "2022-07-24" "2022-07-25" "2022-07-26" "2022-07-27" "2022-07-28"
[516] "2022-07-29" "2022-07-30" "2022-07-31" "2022-08-01" "2022-08-02"
[521] "2022-08-03" "2022-08-04" "2022-08-05" "2022-08-06" "2022-08-07"
[526] "2022-08-08" "2022-08-09" "2022-08-10" "2022-08-11" "2022-08-12"
[531] "2022-08-13" "2022-08-14" "2022-08-15" "2022-08-16" "2022-08-17"
[536] "2022-08-18" "2022-08-19" "2022-08-20" "2022-08-21" "2022-08-22"
[541] "2022-08-23" "2022-08-24" "2022-08-25" "2022-08-26" "2022-08-27"
[546] "2022-08-28" "2022-08-29" "2022-08-30" "2022-08-31" "2022-09-01"
[551] "2022-09-02" "2022-09-03" "2022-09-04" "2022-09-05" "2022-09-06"
[556] "2022-09-07" "2022-09-08" "2022-09-09" "2022-09-10" "2022-09-11"
[561] "2022-09-12" "2022-09-13" "2022-09-14" "2022-09-15" "2022-09-16"
[566] "2022-09-17" "2022-09-18" "2022-09-19" "2022-09-20" "2022-09-21"
[571] "2022-09-22" "2022-09-23" "2022-09-24" "2022-09-25" "2022-09-26"
[576] "2022-09-27" "2022-09-28" "2022-09-29" "2022-09-30" "2022-10-01"
[581] "2022-10-02" "2022-10-03" "2022-10-04" "2022-10-05" "2022-10-06"
[586] "2022-10-07" "2022-10-08" "2022-10-09" "2022-10-10" "2022-10-11"
[591] "2022-10-12" "2022-10-13" "2022-10-14" "2022-10-15" "2022-10-16"
[596] "2022-10-17" "2022-10-18" "2022-10-19" "2022-10-20" "2022-10-21"
[601] "2022-10-22" "2022-10-23" "2022-10-24" "2022-10-25" "2022-10-26"
[606] "2022-10-27" "2022-10-28" "2022-10-29" "2022-10-30" "2022-10-31"
[611] "2022-11-01" "2022-11-02" "2022-11-03" "2022-11-04" "2022-11-05"
[616] "2022-11-06" "2022-11-07" "2022-11-08" "2022-11-09" "2022-11-10"
[621] "2022-11-11" "2022-11-12" "2022-11-13" "2022-11-14" "2022-11-15"
[626] "2022-11-16" "2022-11-17" "2022-11-18" "2022-11-19" "2022-11-20"
[631] "2022-11-21" "2022-11-22" "2022-11-23" "2022-11-24" "2022-11-25"
[636] "2022-11-26" "2022-11-27" "2022-11-28" "2022-11-29" "2022-11-30"
[641] "2022-12-01" "2022-12-02" "2022-12-03" "2022-12-04" "2022-12-05"
[646] "2022-12-06" "2022-12-07" "2022-12-08" "2022-12-09" "2022-12-10"
[651] "2022-12-11" "2022-12-12" "2022-12-13" "2022-12-14" "2022-12-15"
[656] "2022-12-16" "2022-12-17" "2022-12-18" "2022-12-19" "2022-12-20"
[661] "2022-12-21" "2022-12-22" "2022-12-23" "2022-12-24" "2022-12-25"
[666] "2022-12-26" "2022-12-27" "2022-12-28" "2022-12-29" "2022-12-30"
[671] "2022-12-31" "2023-01-01" "2023-01-02" "2023-01-03" "2023-01-04"
[676] "2023-01-05" "2023-01-06" "2023-01-07" "2023-01-08" "2023-01-09"
[681] "2023-01-10" "2023-01-11" "2023-01-12" "2023-01-13" "2023-01-14"
[686] "2023-01-15" "2023-01-16" "2023-01-17" "2023-01-18" "2023-01-19"
[691] "2023-01-20" "2023-01-21" "2023-01-22" "2023-01-23" "2023-01-24"
[696] "2023-01-25" "2023-01-26" "2023-01-27" "2023-01-28" "2023-01-29"
[701] "2023-01-30" "2023-01-31" "2023-02-01" "2023-02-02" "2023-02-03"
[706] "2023-02-04" "2023-02-05" "2023-02-06" "2023-02-07" "2023-02-08"
[711] "2023-02-09" "2023-02-10" "2023-02-11" "2023-02-12" "2023-02-13"
[716] "2023-02-14" "2023-02-15" "2023-02-16" "2023-02-17" "2023-02-18"
[721] "2023-02-19" "2023-02-20" "2023-02-21" "2023-02-22" "2023-02-23"
[726] "2023-02-24" "2023-02-25" "2023-02-26" "2023-02-27" "2023-02-28"
[731] "2023-03-01" "2023-03-02" "2023-03-03" "2023-03-04" "2023-03-05"
[736] "2023-03-06" "2023-03-07" "2023-03-08" "2023-03-09" "2023-03-10"
[741] "2023-03-11" "2023-03-12" "2023-03-13" "2023-03-14" "2023-03-15"
[746] "2023-03-16" "2023-03-17" "2023-03-18" "2023-03-19" "2023-03-20"
[751] "2023-03-21" "2023-03-22" "2023-03-23" "2023-03-24" "2023-03-25"
[756] "2023-03-26" "2023-03-27" "2023-03-28" "2023-03-29" "2023-03-30"
[761] "2023-03-31" "2023-04-01" "2023-04-02" "2023-04-03" "2023-04-04"
[766] "2023-04-05" "2023-04-06" "2023-04-07" "2023-04-08" "2023-04-09"
[771] "2023-04-10" "2023-04-11" "2023-04-12" "2023-04-13" "2023-04-14"
[776] "2023-04-15" "2023-04-16" "2023-04-17" "2023-04-18" "2023-04-19"
[781] "2023-04-20" "2023-04-21" "2023-04-22" "2023-04-23" "2023-04-24"
[786] "2023-04-25" "2023-04-26" "2023-04-27" "2023-04-28" "2023-04-29"
[791] "2023-04-30" "2023-05-01" "2023-05-02" "2023-05-03" "2023-05-04"
[796] "2023-05-05" "2023-05-06" "2023-05-07" "2023-05-08" "2023-05-09"
[801] "2023-05-10" "2023-05-11" "2023-05-12" "2023-05-13" "2023-05-14"
[806] "2023-05-15" "2023-05-16" "2023-05-17" "2023-05-18" "2023-05-19"
[811] "2023-05-20" "2023-05-21" "2023-05-22" "2023-05-23" "2023-05-24"
[816] "2023-05-25" "2023-05-26" "2023-05-27" "2023-05-28" "2023-05-29"
[821] "2023-05-30" "2023-05-31" "2023-06-01" "2023-06-02" "2023-06-03"
[826] "2023-06-04" "2023-06-05" "2023-06-06" "2023-06-07" "2023-06-08"
[831] "2023-06-09" "2023-06-10" "2023-06-11" "2023-06-12" "2023-06-13"
[836] "2023-06-14" "2023-06-15" "2023-06-16" "2023-06-17" "2023-06-18"
[841] "2023-06-19" "2023-06-20" "2023-06-21" "2023-06-22" "2023-06-23"
[846] "2023-06-24" "2023-06-25" "2023-06-26" "2023-06-27" "2023-06-28"
[851] "2023-06-29" "2023-06-30" "2023-07-01" "2023-07-02" "2023-07-03"
[856] "2023-07-04" "2023-07-05" "2023-07-06" "2023-07-07" "2023-07-08"
[861] "2023-07-09" "2023-07-10" "2023-07-11" "2023-07-12" "2023-07-13"
[866] "2023-07-14" "2023-07-15" "2023-07-16" "2023-07-17" "2023-07-18"
[871] "2023-07-19" "2023-07-20" "2023-07-21" "2023-07-22" "2023-07-23"
[876] "2023-07-24" "2023-07-25" "2023-07-26" "2023-07-27" "2023-07-28"
[881] "2023-07-29" "2023-07-30" "2023-07-31" "2023-08-01" "2023-08-02"
[886] "2023-08-03" "2023-08-04" "2023-08-05" "2023-08-06" "2023-08-07"
[891] "2023-08-08" "2023-08-09" "2023-08-10" "2023-08-11" "2023-08-12"
[896] "2023-08-13" "2023-08-14" "2023-08-15" "2023-08-16" "2023-08-17"
[901] "2023-08-18" "2023-08-19" "2023-08-20" "2023-08-21" "2023-08-22"
[906] "2023-08-23" "2023-08-24" "2023-08-25" "2023-08-26" "2023-08-27"
[911] "2023-08-28" "2023-08-29" "2023-08-30" "2023-08-31" "2023-09-01"
[916] "2023-09-02" "2023-09-03" "2023-09-04" "2023-09-05" "2023-09-06"
[921] "2023-09-07" "2023-09-08" "2023-09-09" "2023-09-10" "2023-09-11"
[926] "2023-09-12" "2023-09-13" "2023-09-14" "2023-09-15" "2023-09-16"
[931] "2023-09-17" "2023-09-18" "2023-09-19" "2023-09-20" "2023-09-21"
[936] "2023-09-22" "2023-09-23" "2023-09-24" "2023-09-25" "2023-09-26"
[941] "2023-09-27" "2023-09-28" "2023-09-29" "2023-09-30" "2023-10-01"
[946] "2023-10-02" "2023-10-03" "2023-10-04" "2023-10-05" "2023-10-06"
[951] "2023-10-07" "2023-10-08" "2023-10-09" "2023-10-10" "2023-10-11"
[956] "2023-10-12" "2023-10-13" "2023-10-14" "2023-10-15" "2023-10-16"
[961] "2023-10-17" "2023-10-18" "2023-10-19" "2023-10-20" "2023-10-21"
[966] "2023-10-22" "2023-10-23" "2023-10-24" "2023-10-25" "2023-10-26"
[971] "2023-10-27" "2023-10-28" "2023-10-29" "2023-10-30" "2023-10-31"
[976] "2023-11-01" "2023-11-02" "2023-11-03" "2023-11-04" "2023-11-05"
[981] "2023-11-06" "2023-11-07" "2023-11-08" "2023-11-09" "2023-11-10"
[986] "2023-11-11" "2023-11-12" "2023-11-13" "2023-11-14" "2023-11-15"
[991] "2023-11-16" "2023-11-17" "2023-11-18" "2023-11-19" "2023-11-20"
[996] "2023-11-21" "2023-11-22" "2023-11-23" "2023-11-24" "2023-11-25"
[1001] "2023-11-26" "2023-11-27" "2023-11-28" "2023-11-29" "2023-11-30"
[1006] "2023-12-01" "2023-12-02" "2023-12-03" "2023-12-04" "2023-12-05"
[1011] "2023-12-06" "2023-12-07" "2023-12-08" "2023-12-09" "2023-12-10"
[1016] "2023-12-11" "2023-12-12" "2023-12-13" "2023-12-14" "2023-12-15"
[1021] "2023-12-16" "2023-12-17" "2023-12-18" "2023-12-19" "2023-12-20"
[1026] "2023-12-21" "2023-12-22" "2023-12-23" "2023-12-24" "2023-12-25"
[1031] "2023-12-26" "2023-12-27" "2023-12-28" "2023-12-29" "2023-12-30"
[1036] "2023-12-31" "2024-01-01" "2024-01-02" "2024-01-03" "2024-01-04"
[1041] "2024-01-05" "2024-01-06" "2024-01-07" "2024-01-08" "2024-01-09"
[1046] "2024-01-10" "2024-01-11" "2024-01-12" "2024-01-13" "2024-01-14"
[1051] "2024-01-15" "2024-01-16" "2024-01-17" "2024-01-18" "2024-01-19"
[1056] "2024-01-20" "2024-01-21" "2024-01-22" "2024-01-23" "2024-01-24"
[1061] "2024-01-25" "2024-01-26" "2024-01-27" "2024-01-28" "2024-01-29"
[1066] "2024-01-30" "2024-01-31" "2024-02-01" "2024-02-02" "2024-02-03"
[1071] "2024-02-04" "2024-02-05" "2024-02-06" "2024-02-07" "2024-02-08"
[1076] "2024-02-09" "2024-02-10" "2024-02-11" "2024-02-12" "2024-02-13"
[1081] "2024-02-14" "2024-02-15" "2024-02-16" "2024-02-17" "2024-02-18"
[1086] "2024-02-19" "2024-02-20" "2024-02-21" "2024-02-22" "2024-02-23"
[1091] "2024-02-24" "2024-02-25" "2024-02-26" "2024-02-27" "2024-02-28"
[1096] "2024-02-29" "2024-03-01" "2024-03-02" "2024-03-03" "2024-03-04"
[1101] "2024-03-05" "2024-03-06" "2024-03-07" "2024-03-08" "2024-03-09"
[1106] "2024-03-10" "2024-03-11" "2024-03-12" "2024-03-13" "2024-03-14"
[1111] "2024-03-15" "2024-03-16" "2024-03-17" "2024-03-18" "2024-03-19"
[1116] "2024-03-20" "2024-03-21" "2024-03-22" "2024-03-23" "2024-03-24"
[1121] "2024-03-25" "2024-03-26" "2024-03-27" "2024-03-28" "2024-03-29"
[1126] "2024-03-30" "2024-03-31" "2024-04-01" "2024-04-02" "2024-04-03"
[1131] "2024-04-04" "2024-04-05" "2024-04-06" "2024-04-07" "2024-04-08"
[1136] "2024-04-09" "2024-04-10" "2024-04-11" "2024-04-12" "2024-04-13"
[1141] "2024-04-14" "2024-04-15" "2024-04-16" "2024-04-17" "2024-04-18"
[1146] "2024-04-19" "2024-04-20" "2024-04-21" "2024-04-22" "2024-04-23"
[1151] "2024-04-24" "2024-04-25" "2024-04-26" "2024-04-27" "2024-04-28"
[1156] "2024-04-29" "2024-04-30" "2024-05-01" "2024-05-02" "2024-05-03"
[1161] "2024-05-04" "2024-05-05" "2024-05-06" "2024-05-07" "2024-05-08"
[1166] "2024-05-09" "2024-05-10" "2024-05-11" "2024-05-12" "2024-05-13"
[1171] "2024-05-14" "2024-05-15" "2024-05-16" "2024-05-17" "2024-05-18"
[1176] "2024-05-19" "2024-05-20" "2024-05-21" "2024-05-22" "2024-05-23"
[1181] "2024-05-24" "2024-05-25" "2024-05-26" "2024-05-27" "2024-05-28"
[1186] "2024-05-29" "2024-05-30" "2024-05-31" "2024-06-01" "2024-06-02"
[1191] "2024-06-03" "2024-06-04" "2024-06-05" "2024-06-06" "2024-06-07"
[1196] "2024-06-08" "2024-06-09" "2024-06-10" "2024-06-11" "2024-06-12"
[1201] "2024-06-13" "2024-06-14" "2024-06-15" "2024-06-16" "2024-06-17"
[1206] "2024-06-18" "2024-06-19" "2024-06-20" "2024-06-21" "2024-06-22"
[1211] "2024-06-23" "2024-06-24" "2024-06-25" "2024-06-26" "2024-06-27"
[1216] "2024-06-28" "2024-06-29" "2024-06-30" "2024-07-01" "2024-07-02"
[1221] "2024-07-03" "2024-07-04" "2024-07-05" "2024-07-06" "2024-07-07"
[1226] "2024-07-08" "2024-07-09" "2024-07-10" "2024-07-11" "2024-07-12"
[1231] "2024-07-13" "2024-07-14" "2024-07-15" "2024-07-16" "2024-07-17"
[1236] "2024-07-18" "2024-07-19" "2024-07-20" "2024-07-21" "2024-07-22"
[1241] "2024-07-23" "2024-07-24" "2024-07-25" "2024-07-26" "2024-07-27"
[1246] "2024-07-28" "2024-07-29" "2024-07-30" "2024-07-31" "2024-08-01"
[1251] "2024-08-02" "2024-08-03" "2024-08-04" "2024-08-05" "2024-08-06"
[1256] "2024-08-07" "2024-08-08" "2024-08-09" "2024-08-10" "2024-08-11"
[1261] "2024-08-12" "2024-08-13" "2024-08-14" "2024-08-15" "2024-08-16"
[1266] "2024-08-17" "2024-08-18" "2024-08-19" "2024-08-20" "2024-08-21"
[1271] "2024-08-22" "2024-08-23" "2024-08-24" "2024-08-25" "2024-08-26"
[1276] "2024-08-27" "2024-08-28" "2024-08-29" "2024-08-30" "2024-08-31"
[1281] "2024-09-01" "2024-09-02" "2024-09-03" "2024-09-04" "2024-09-05"
[1286] "2024-09-06" "2024-09-07" "2024-09-08" "2024-09-09" "2024-09-10"
[1291] "2024-09-11" "2024-09-12" "2024-09-13" "2024-09-14" "2024-09-15"
[1296] "2024-09-16" "2024-09-17" "2024-09-18" "2024-09-19" "2024-09-20"
[1301] "2024-09-21" "2024-09-22" "2024-09-23" "2024-09-24" "2024-09-25"
[1306] "2024-09-26" "2024-09-27" "2024-09-28" "2024-09-29" "2024-09-30"
[1311] "2024-10-01" "2024-10-02" "2024-10-03" "2024-10-04" "2024-10-05"
[1316] "2024-10-06" "2024-10-07" "2024-10-08" "2024-10-09" "2024-10-10"
[1321] "2024-10-11" "2024-10-12" "2024-10-13" "2024-10-14" "2024-10-15"
[1326] "2024-10-16" "2024-10-17" "2024-10-18" "2024-10-19" "2024-10-20"
[1331] "2024-10-21" "2024-10-22" "2024-10-23" "2024-10-24" "2024-10-25"
[1336] "2024-10-26" "2024-10-27" "2024-10-28" "2024-10-29" "2024-10-30"
[1341] "2024-10-31" "2024-11-01" "2024-11-02" "2024-11-03" "2024-11-04"
[1346] "2024-11-05" "2024-11-06" "2024-11-07" "2024-11-08" "2024-11-09"
[1351] "2024-11-10" "2024-11-11" "2024-11-12" "2024-11-13" "2024-11-14"
[1356] "2024-11-15" "2024-11-16" "2024-11-17" "2024-11-18" "2024-11-19"
[1361] "2024-11-20" "2024-11-21" "2024-11-22" "2024-11-23" "2024-11-24"
[1366] "2024-11-25" "2024-11-26" "2024-11-27" "2024-11-28" "2024-11-29"
[1371] "2024-11-30" "2024-12-01" "2024-12-02" "2024-12-03" "2024-12-04"
[1376] "2024-12-05" "2024-12-06" "2024-12-07" "2024-12-08" "2024-12-09"
[1381] "2024-12-10" "2024-12-11" "2024-12-12" "2024-12-13" "2024-12-14"
[1386] "2024-12-15" "2024-12-16" "2024-12-17" "2024-12-18" "2024-12-19"
[1391] "2024-12-20" "2024-12-21" "2024-12-22" "2024-12-23" "2024-12-24"
[1396] "2024-12-25" "2024-12-26" "2024-12-27" "2024-12-28" "2024-12-29"
[1401] "2024-12-30" "2024-12-31" "2025-01-01" "2025-01-02" "2025-01-03"
[1406] "2025-01-04" "2025-01-05" "2025-01-06" "2025-01-07" "2025-01-08"
[1411] "2025-01-09" "2025-01-10" "2025-01-11" "2025-01-12" "2025-01-13"
[1416] "2025-01-14" "2025-01-15" "2025-01-16" "2025-01-17" "2025-01-18"
[1421] "2025-01-19" "2025-01-20" "2025-01-21" "2025-01-22" "2025-01-23"
[1426] "2025-01-24" "2025-01-25" "2025-01-26" "2025-01-27" "2025-01-28"
[1431] "2025-01-29" "2025-01-30" "2025-01-31" "2025-02-01" "2025-02-02"
[1436] "2025-02-03" "2025-02-04" "2025-02-05" "2025-02-06" "2025-02-07"
[1441] "2025-02-08" "2025-02-09" "2025-02-10" "2025-02-11" "2025-02-12"
[1446] "2025-02-13" "2025-02-14" "2025-02-15" "2025-02-16" "2025-02-17"
[1451] "2025-02-18" "2025-02-19" "2025-02-20" "2025-02-21" "2025-02-22"
[1456] "2025-02-23" "2025-02-24" "2025-02-25" "2025-02-26" "2025-02-27"
[1461] "2025-02-28" "2025-03-01" "2025-03-02" "2025-03-03" "2025-03-04"
[1466] "2025-03-05" "2025-03-06" "2025-03-07" "2025-03-08" "2025-03-09"
[1471] "2025-03-10" "2025-03-11" "2025-03-12" "2025-03-13" "2025-03-14"
[1476] "2025-03-15" "2025-03-16" "2025-03-17" "2025-03-18" "2025-03-19"
[1481] "2025-03-20" "2025-03-21" "2025-03-22" "2025-03-23" "2025-03-24"
[1486] "2025-03-25" "2025-03-26" "2025-03-27" "2025-03-28" "2025-03-29"
[1491] "2025-03-30" "2025-03-31" "2025-04-01" "2025-04-02" "2025-04-03"
[1496] "2025-04-04" "2025-04-05" "2025-04-06" "2025-04-07" "2025-04-08"
[1501] "2025-04-09" "2025-04-10" "2025-04-11" "2025-04-12" "2025-04-13"
[1506] "2025-04-14" "2025-04-15" "2025-04-16" "2025-04-17" "2025-04-18"
[1511] "2025-04-19" "2025-04-20" "2025-04-21" "2025-04-22" "2025-04-23"
[1516] "2025-04-24" "2025-04-25" "2025-04-26" "2025-04-27" "2025-04-28"
[1521] "2025-04-29" "2025-04-30" "2025-05-01" "2025-05-02" "2025-05-03"
[1526] "2025-05-04" "2025-05-05" "2025-05-06" "2025-05-07" "2025-05-08"
[1531] "2025-05-09" "2025-05-10" "2025-05-11" "2025-05-12" "2025-05-13"
[1536] "2025-05-14" "2025-05-15" "2025-05-16" "2025-05-17" "2025-05-18"
[1541] "2025-05-19" "2025-05-20" "2025-05-21" "2025-05-22" "2025-05-23"
[1546] "2025-05-24" "2025-05-25" "2025-05-26" "2025-05-27" "2025-05-28"
[1551] "2025-05-29" "2025-05-30" "2025-05-31" "2025-06-01" "2025-06-02"
[1556] "2025-06-03" "2025-06-04" "2025-06-05" "2025-06-06" "2025-06-07"
[1561] "2025-06-08" "2025-06-09" "2025-06-10" "2025-06-11" "2025-06-12"
[1566] "2025-06-13" "2025-06-14" "2025-06-15" "2025-06-16" "2025-06-17"
[1571] "2025-06-18" "2025-06-19" "2025-06-20" "2025-06-21" "2025-06-22"
[1576] "2025-06-23" "2025-06-24" "2025-06-25" "2025-06-26" "2025-06-27"
[1581] "2025-06-28" "2025-06-29" "2025-06-30" "2025-07-01" "2025-07-02"
[1586] "2025-07-03" "2025-07-04" "2025-07-05" "2025-07-06" "2025-07-07"
[1591] "2025-07-08" "2025-07-09" "2025-07-10" "2025-07-11" "2025-07-12"
[1596] "2025-07-13" "2025-07-14" "2025-07-15" "2025-07-16" "2025-07-17"
[1601] "2025-07-18" "2025-07-19" "2025-07-20" "2025-07-21" "2025-07-22"
[1606] "2025-07-23" "2025-07-24" "2025-07-25" "2025-07-26" "2025-07-27"
[1611] "2025-07-28" "2025-07-29" "2025-07-30" "2025-07-31" "2025-08-01"
[1616] "2025-08-02" "2025-08-03" "2025-08-04" "2025-08-05" "2025-08-06"
[1621] "2025-08-07" "2025-08-08" "2025-08-09" "2025-08-10" "2025-08-11"
[1626] "2025-08-12" "2025-08-13" "2025-08-14" "2025-08-15" "2025-08-16"
[1631] "2025-08-17" "2025-08-18" "2025-08-19" "2025-08-20" "2025-08-21"
[1636] "2025-08-22" "2025-08-23" "2025-08-24" "2025-08-25" "2025-08-26"
[1641] "2025-08-27" "2025-08-28" "2025-08-29" "2025-08-30" "2025-08-31"
[1646] "2025-09-01" "2025-09-02" "2025-09-03" "2025-09-04" "2025-09-05"
[1651] "2025-09-06" "2025-09-07" "2025-09-08" "2025-09-09" "2025-09-10"
[1656] "2025-09-11" "2025-09-12" "2025-09-13" "2025-09-14" "2025-09-15"
[1661] "2025-09-16" "2025-09-17" "2025-09-18" "2025-09-19" "2025-09-20"
[1666] "2025-09-21" "2025-09-22" "2025-09-23" "2025-09-24" "2025-09-25"
[1671] "2025-09-26" "2025-09-27" "2025-09-28" "2025-09-29" "2025-09-30"
[1676] "2025-10-01" "2025-10-02" "2025-10-03" "2025-10-04" "2025-10-05"
[1681] "2025-10-06" "2025-10-07" "2025-10-08" "2025-10-09" "2025-10-10"
[1686] "2025-10-11" "2025-10-12" "2025-10-13" "2025-10-14" "2025-10-15"
[1691] "2025-10-16" "2025-10-17" "2025-10-18" "2025-10-19" "2025-10-20"
[1696] "2025-10-21" "2025-10-22" "2025-10-23" "2025-10-24" "2025-10-25"
[1701] "2025-10-26" "2025-10-27" "2025-10-28" "2025-10-29" "2025-10-30"
[1706] "2025-10-31" "2025-11-01" "2025-11-02" "2025-11-03" "2025-11-04"
[1711] "2025-11-05" "2025-11-06" "2025-11-07" "2025-11-08" "2025-11-09"
[1716] "2025-11-10" "2025-11-11" "2025-11-12" "2025-11-13" "2025-11-14"
[1721] "2025-11-15" "2025-11-16" "2025-11-17" "2025-11-18" "2025-11-19"
[1726] "2025-11-20" "2025-11-21" "2025-11-22" "2025-11-23" "2025-11-24"
[1731] "2025-11-25" "2025-11-26" "2025-11-27" "2025-11-28" "2025-11-29"
[1736] "2025-11-30" "2025-12-01" "2025-12-02" "2025-12-03" "2025-12-04"
[1741] "2025-12-05" "2025-12-06" "2025-12-07" "2025-12-08" "2025-12-09"
[1746] "2025-12-10" "2025-12-11" "2025-12-12" "2025-12-13" "2025-12-14"
[1751] "2025-12-15" "2025-12-16" "2025-12-17" "2025-12-18" "2025-12-19"
[1756] "2025-12-20" "2025-12-21" "2025-12-22" "2025-12-23" "2025-12-24"
[1761] "2025-12-25" "2025-12-26" "2025-12-27" "2025-12-28" "2025-12-29"
[1766] "2025-12-30" "2025-12-31" "2026-01-01" "2026-01-02" "2026-01-03"
[1771] "2026-01-04" "2026-01-05" "2026-01-06" "2026-01-07" "2026-01-08"
[1776] "2026-01-09" "2026-01-10" "2026-01-11" "2026-01-12" "2026-01-13"
[1781] "2026-01-14" "2026-01-15" "2026-01-16" "2026-01-17" "2026-01-18"
[1786] "2026-01-19" "2026-01-20" "2026-01-21" "2026-01-22" "2026-01-23"
[1791] "2026-01-24" "2026-01-25" "2026-01-26" "2026-01-27" "2026-01-28"
[1796] "2026-01-29" "2026-01-30" "2026-01-31" "2026-02-01" "2026-02-02"
[1801] "2026-02-03" "2026-02-04" "2026-02-05" "2026-02-06" "2026-02-07"
[1806] "2026-02-08" "2026-02-09" "2026-02-10" "2026-02-11" "2026-02-12"
[1811] "2026-02-13" "2026-02-14" "2026-02-15" "2026-02-16" "2026-02-17"
[1816] "2026-02-18" "2026-02-19" "2026-02-20" "2026-02-21" "2026-02-22"
[1821] "2026-02-23" "2026-02-24" "2026-02-25" "2026-02-26" "2026-02-27"
[1826] "2026-02-28" "2026-03-01" "2026-03-02" "2026-03-03" "2026-03-04"
[1831] "2026-03-05" "2026-03-06" "2026-03-07" "2026-03-08" "2026-03-09"
[1836] "2026-03-10" "2026-03-11" "2026-03-12" "2026-03-13" "2026-03-14"
[1841] "2026-03-15" "2026-03-16" "2026-03-17" "2026-03-18" "2026-03-19"
[1846] "2026-03-20" "2026-03-21" "2026-03-22" "2026-03-23" "2026-03-24"
[1851] "2026-03-25" "2026-03-26" "2026-03-27" "2026-03-28" "2026-03-29"
[1856] "2026-03-30" "2026-03-31" "2026-04-01" "2026-04-02" "2026-04-03"
[1861] "2026-04-04" "2026-04-05" "2026-04-06" "2026-04-07" "2026-04-08"
[1866] "2026-04-09" "2026-04-10" "2026-04-11" "2026-04-12" "2026-04-13"
[1871] "2026-04-14" "2026-04-15" "2026-04-16" "2026-04-17" "2026-04-18"
[1876] "2026-04-19" "2026-04-20" "2026-04-21" "2026-04-22" "2026-04-23"
[1881] "2026-04-24" "2026-04-25" "2026-04-26" "2026-04-27" "2026-04-28"
[1886] "2026-04-29" "2026-04-30" "2026-05-01" "2026-05-02" "2026-05-03"
[1891] "2026-05-04" "2026-05-05" "2026-05-06" "2026-05-07" "2026-05-08"
[1896] "2026-05-09" "2026-05-10" "2026-05-11" "2026-05-12" "2026-05-13"
[1901] "2026-05-14" "2026-05-15" "2026-05-16" "2026-05-17" "2026-05-18"
[1906] "2026-05-19" "2026-05-20" "2026-05-21" "2026-05-22" "2026-05-23"
[1911] "2026-05-24" "2026-05-25" "2026-05-26" "2026-05-27" "2026-05-28"
[1916] "2026-05-29" "2026-05-30" "2026-05-31" "2026-06-01" "2026-06-02"
[1921] "2026-06-03" "2026-06-04" "2026-06-05" "2026-06-06" "2026-06-07"
[1926] "2026-06-08" "2026-06-09" "2026-06-10" "2026-06-11" "2026-06-12"
[1931] "2026-06-13" "2026-06-14" "2026-06-15" "2026-06-16" "2026-06-17"
[1936] "2026-06-18" "2026-06-19" "2026-06-20" "2026-06-21" "2026-06-22"
[1941] "2026-06-23" "2026-06-24" "2026-06-25" "2026-06-26" "2026-06-27"
[1946] "2026-06-28" "2026-06-29" "2026-06-30" "2026-07-01" "2026-07-02"
[1951] "2026-07-03" "2026-07-04" "2026-07-05" "2026-07-06" "2026-07-07"
[1956] "2026-07-08" "2026-07-09" "2026-07-10" "2026-07-11" "2026-07-12"
[1961] "2026-07-13" "2026-07-14" "2026-07-15" "2026-07-16" "2026-07-17"
[1966] "2026-07-18" "2026-07-19" "2026-07-20" "2026-07-21" "2026-07-22"
[1971] "2026-07-23" "2026-07-24" "2026-07-25" "2026-07-26" "2026-07-27"
[1976] "2026-07-28" "2026-07-29" "2026-07-30" "2026-07-31" "2026-08-01"
[1981] "2026-08-02" "2026-08-03" "2026-08-04" "2026-08-05" "2026-08-06"
[1986] "2026-08-07" "2026-08-08" "2026-08-09" "2026-08-10" "2026-08-11"
[1991] "2026-08-12" "2026-08-13" "2026-08-14" "2026-08-15" "2026-08-16"
[1996] "2026-08-17" "2026-08-18" "2026-08-19" "2026-08-20" "2026-08-21"
[2001] "2026-08-22" "2026-08-23" "2026-08-24" "2026-08-25" "2026-08-26"
[2006] "2026-08-27" "2026-08-28" "2026-08-29" "2026-08-30" "2026-08-31"
[2011] "2026-09-01" "2026-09-02" "2026-09-03" "2026-09-04" "2026-09-05"
[2016] "2026-09-06" "2026-09-07" "2026-09-08" "2026-09-09" "2026-09-10"
[2021] "2026-09-11" "2026-09-12" "2026-09-13" "2026-09-14" "2026-09-15"
[2026] "2026-09-16" "2026-09-17" "2026-09-18" "2026-09-19" "2026-09-20"
One final challenge that will set the scene for next week: Extract each row’s year from the date column. (Remember that you can only extract date information from data that is in date-time format.) This will require multiple lines of code and likely some functions you haven’t used before.
S: Extract years from data
P: Convert column to date-time format. Extract year.
A: Help me extract the year from the date of census column (upload data)
R:
dhs$date_of_census_dt <- mdy(dhs$date_of_census)
dhs$year <- year(dhs$date_of_census_dt)C: The year column is in my data and matches what’s in the date column.
K: The mdy function converted my character data to date-time data. The year function extracted the year.
There are many other sources of data besides NYC Open Data. Let’s move over to some PowerPoint slides to check them out.