R Tutorial: Introduction to dates

DataCamp · Beginner ·🛠️ AI Tools & Apps ·6y ago

Key Takeaways

The video tutorial introduces the basics of working with dates in R, covering the ISO 8601 standard and using the as.Date function to convert character strings to date objects.

Full Transcript

welcome to working with dates and times in our in this course you'll master importing manipulating and computing with dates and times to explore whether scheduled meetings and calculate reigns of monarchs in this chapter you'll learn about hours built-in objects for handling dates and times let's start with dates where I grew up in New Zealand we always put day of the month first then month then year but in the US the convention is month first then day of the month then year this can get confusing surely one of them must be more correct it turns out there is a global standard called ISO 8601 that specifies the correct way to share dates to avoid all confusion it says all of the components and decreasing units that is year month then day turns out both the US and New Zealand conventions are wrong all these other formats also don't comply with ISO 8601 please don't try to give our dates painted on a black cat the ISO 8601 standard specifies the order of the components but also a few other details about the day for example each component has a fixed number of digits year has four and day and month too if you only need one digit for the day or month you must pair it with leading zeros you don't have to use a separator in the ISO standard but if you do it must be a - and dates so the date the 1st of January 2011 an ISO 8601 standard is 2011 - 0 1 - 0 1 if you have a date in the ISO 8601 format it still takes a little work to get our to recognise it as a date if you tried it just in put it on the console I will interpret the dashes as subtraction and you will end up with something a little surprising you might think using quotes will help certainly looks like a date but are still thinks it's just a to string the secret to getting our to recognize dates is telling it explicitly this is a date with the s date function s dot date takes a character string and turns it into a date object it will only work with dates in the ISO order but you'll see how to handle other formats in chapter 2 there are also a couple of packages that will automatically import dates in a wider range of formats you'll see two examples in the exercises read R and any time alright let's get some dates into our

Original Description

Want to learn more? Take the full course at https://learn.datacamp.com/courses/working-with-dates-and-times-in-r at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work. --- Welcome to working with dates and times in R. In this course you'll master importing, manipulating and computing with dates and times to explore weather, schedule meetings and calculate reigns of monarchs. In this chapter you'll learn about R's built-in objects for handling dates and times. Let's start with dates. Where I grew up in New Zealand we always put day of month first, then month, then year. But in the US the convention is month first, then day of month, then year. This can get confusing, surely one of them must be more correct? It turns out there is a global standard called ISO 8601, that specifies the correct way to share dates to avoid all confusion. It says order the components in decreasing units, that is, year, month then day. Turns out both the US and New Zealand conventions are wrong. All these other formats also don't comply with ISO 8601. Please, don't try to give R dates painted on a black cat. The ISO 8601 standard specifies the order of the components, but also a few other details about the date. For example, each component has a fixed number of digits: year has four and day and month two. If you only need one digit for the day or month, you must pad it with leading zeros. You don't have to use separator in the ISO standard but if you do it must be a dash in dates. So, the date, the 1st of January 2011, in ISO 8601 standard is 2011 (dash) 01 (dash) 01. If you have a date in ISO 8601 format, it still takes a little work to get R to recognize it as a date. If you try to just input it on the console, R will interpret the dashes as subtraction and you'll end up with something a little surprising. You might think using quotes will help. It certainly looks like a date, but R still thinks it's just a character string. Th
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DataCamp · DataCamp · 0 of 60

← Previous Next →
1 SQL Server Tutorial: Date manipulation
SQL Server Tutorial: Date manipulation
DataCamp
2 R Tutorial: Intermediate Interactive Data Visualization with plotly in R
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
3 R Tutorial: Adding aesthetics to represent a variable
R Tutorial: Adding aesthetics to represent a variable
DataCamp
4 R Tutorial: Moving Beyond Simple Interactivity
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
5 Python Tutorial: Why use ML for marketing? Strategies and use cases
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
6 Python Tutorial: Preparation for modeling
Python Tutorial: Preparation for modeling
DataCamp
7 Python Tutorial: Machine Learning modeling steps
Python Tutorial: Machine Learning modeling steps
DataCamp
8 R Tutorial: The prior model
R Tutorial: The prior model
DataCamp
9 R Tutorial: Data & the likelihood
R Tutorial: Data & the likelihood
DataCamp
10 R Tutorial: The posterior model
R Tutorial: The posterior model
DataCamp
11 R Tutorial: An Introduction to plotly
R Tutorial: An Introduction to plotly
DataCamp
12 R Tutorial: Plotting a single variable
R Tutorial: Plotting a single variable
DataCamp
13 R Tutorial: Bivariate graphics
R Tutorial: Bivariate graphics
DataCamp
14 Python Tutorial: Customer Segmentation in Python
Python Tutorial: Customer Segmentation in Python
DataCamp
15 Python Tutorial: Time cohorts
Python Tutorial: Time cohorts
DataCamp
16 Python Tutorial: Calculate cohort metrics
Python Tutorial: Calculate cohort metrics
DataCamp
17 Python Tutorial: Cohort analysis visualization
Python Tutorial: Cohort analysis visualization
DataCamp
18 R Tutorial: Building Dashboards with flexdashboard
R Tutorial: Building Dashboards with flexdashboard
DataCamp
19 R Tutorial: Anatomy of a flexdashboard
R Tutorial: Anatomy of a flexdashboard
DataCamp
20 R Tutorial: Layout basics
R Tutorial: Layout basics
DataCamp
21 R Tutorial: Advanced layouts
R Tutorial: Advanced layouts
DataCamp
22 Python Tutorial: Time Series Analysis in Python
Python Tutorial: Time Series Analysis in Python
DataCamp
23 Python Tutorial: Correlation of Two Time Series
Python Tutorial: Correlation of Two Time Series
DataCamp
24 Python Tutorial: Simple Linear Regressions
Python Tutorial: Simple Linear Regressions
DataCamp
25 Python Tutorial: Autocorrelation
Python Tutorial: Autocorrelation
DataCamp
26 R Tutorial: The gapminder dataset
R Tutorial: The gapminder dataset
DataCamp
27 R Tutorial: The filter verb
R Tutorial: The filter verb
DataCamp
28 R Tutorial: The arrange verb
R Tutorial: The arrange verb
DataCamp
29 R Tutorial: The mutate verb
R Tutorial: The mutate verb
DataCamp
30 R Tutorial: What is cluster analysis?
R Tutorial: What is cluster analysis?
DataCamp
31 R Tutorial: Distance between two observations
R Tutorial: Distance between two observations
DataCamp
32 R Tutorial: The importance of scale
R Tutorial: The importance of scale
DataCamp
33 R Tutorial: Measuring distance for categorical data
R Tutorial: Measuring distance for categorical data
DataCamp
34 Python Tutorial: Plotting multiple graphs
Python Tutorial: Plotting multiple graphs
DataCamp
35 Python Tutorial: Customizing axes
Python Tutorial: Customizing axes
DataCamp
36 Python Tutorial: Legends, annotations, & styles
Python Tutorial: Legends, annotations, & styles
DataCamp
37 Python Tutorial: Introduction to iterators
Python Tutorial: Introduction to iterators
DataCamp
38 Python Tutorial: Playing with iterators
Python Tutorial: Playing with iterators
DataCamp
39 Python Tutorial: Using iterators to load large files into memory
Python Tutorial: Using iterators to load large files into memory
DataCamp
40 SQL Tutorial: Introduction to Relational Databases in SQL
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
41 SQL Tutorial: Tables: At the core of every database
SQL Tutorial: Tables: At the core of every database
DataCamp
42 SQL Tutorial: Update your database as the structure changes
SQL Tutorial: Update your database as the structure changes
DataCamp
43 Python Tutorial: Classification-Tree Learning
Python Tutorial: Classification-Tree Learning
DataCamp
44 Python Tutorial: Decision-Tree for Classification
Python Tutorial: Decision-Tree for Classification
DataCamp
45 Python Tutorial: Decision-Tree for Regression
Python Tutorial: Decision-Tree for Regression
DataCamp
46 Python Tutorial: Census Subject Tables
Python Tutorial: Census Subject Tables
DataCamp
47 Python Tutorial: Census Geography
Python Tutorial: Census Geography
DataCamp
48 Python Tutorial: Using the Census API
Python Tutorial: Using the Census API
DataCamp
49 R Tutorial: A/B Testing in R
R Tutorial: A/B Testing in R
DataCamp
50 R Tutorial: Baseline Conversion Rates
R Tutorial: Baseline Conversion Rates
DataCamp
51 R Tutorial: Designing an Experiment - Power Analysis
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
52 R Tutorial: Introduction to qualitative data
R Tutorial: Introduction to qualitative data
DataCamp
53 R Tutorial: Understanding your qualitative variables
R Tutorial: Understanding your qualitative variables
DataCamp
54 R Tutorial: Making Better Plots
R Tutorial: Making Better Plots
DataCamp
55 SQL Tutorial: OLTP and OLAP
SQL Tutorial: OLTP and OLAP
DataCamp
56 SQL Tutorial: Storing data
SQL Tutorial: Storing data
DataCamp
57 SQL Tutorial: Database design
SQL Tutorial: Database design
DataCamp
58 Python Tutorial: Introduction to spaCy
Python Tutorial: Introduction to spaCy
DataCamp
59 Python Tutorial: Statistical Models
Python Tutorial: Statistical Models
DataCamp
60 Python Tutorial: Rule-based Matching
Python Tutorial: Rule-based Matching
DataCamp

This video tutorial teaches the basics of working with dates in R, including the ISO 8601 standard and how to use the as.Date function to convert character strings to date objects. It provides a foundation for further learning and hands-on practice with dates in R.

Key Takeaways
  1. Understand the ISO 8601 standard for dates
  2. Learn how to use the as.Date function in R
  3. Practice converting character strings to date objects
  4. Explore handling dates in different formats
  5. Use packages to automatically import dates in various formats
💡 The ISO 8601 standard provides a global standard for sharing dates, and the as.Date function in R is used to convert character strings to date objects.

Related Reads

📰
I Asked Claude to Audit My Entire Income Strategy. What It Found Was Uncomfortable.
Using AI to audit income strategy reveals uncomfortable truths, highlighting the importance of objective analysis in personal finance
Medium · AI
📰
7 AI Tools Every Freelancer Should Learn in 2026 (To Work Smarter, Not Harder)
Learn 7 essential AI tools to boost your freelancing career and work smarter, not harder
Medium · AI
📰
How to prepare for Spain civil service TIC exam using AI in 2026
Learn how to leverage AI tools to prepare for the Spain Civil Service TIC exam in 2026, improving your chances of success
Dev.to AI
📰
AI-Powered Sample Clearance: Building Legally-Aware Reports for Independent Producers
Learn how AI-powered sample clearance can help independent music producers navigate copyright risks and create legally-aware reports
Dev.to AI
Up next
14+ Free Google AI Tools for Research & Learning You Should Know
Growth Learner
Watch →