Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Wrangling with R

You're reading from   Data Wrangling with R Load, explore, transform and visualize data for modeling with tidyverse libraries

Arrow left icon
Product type Paperback
Published in Feb 2023
Publisher Packt
ISBN-13 9781803235400
Length 384 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Gustavo Santos Gustavo Santos
Author Profile Icon Gustavo Santos
Gustavo Santos
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Load and Explore Data
2. Chapter 1: Fundamentals of Data Wrangling FREE CHAPTER 3. Chapter 2: Loading and Exploring Datasets 4. Chapter 3: Basic Data Visualization 5. Part 2: Data Wrangling
6. Chapter 4: Working with Strings 7. Chapter 5: Working with Numbers 8. Chapter 6: Working with Date and Time Objects 9. Chapter 7: Transformations with Base R 10. Chapter 8: Transformations with Tidyverse Libraries 11. Chapter 9: Exploratory Data Analysis 12. Part 3: Data Visualization
13. Chapter 10: Introduction to ggplot2 14. Chapter 11: Enhanced Visualizations with ggplot2 15. Chapter 12: Other Data Visualization Options 16. Part 4: Modeling
17. Chapter 13: Building a Model with R 18. Chapter 14: Build an Application with Shiny in R 19. Conclusion 20. Other Books You May Enjoy

Time series plots

A time series is a sequence of data points ordered by time. In a time series, the data points are measurements of any given variable throughout time, such as days, hours, months, or any other time frame. We can visualize time series using ggplot2 as long as the dataset contains a datetime variable. The best way to visualize data organized by time is with line plots. Let’s set a seed so you can reproduce the same results as mine for the random numbers. Create a sample dataframe and then see how to visualize a time series:

# Set seed to reproduce the same random numbers
set.seed(10)
# Creating a Dataset
ts <- data.frame(
  date = seq(ymd('2022-01-01'),ymd('2022-06-30'),by='days'),
  measure = as.integer(runif(181, min=600,  max= 1000) + sort(rexp(181,0.001)))

The preceding code is a data.frame object where we are assigning a sequence of dates to the name date from January 1 to June 3, 2022,...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime