Skip to Content
Advancing into Analytics
book

Advancing into Analytics

by George Mount
April 2021
Beginner to intermediate
248 pages
6h 26m
English
O'Reilly Media, Inc.
Content preview from Advancing into Analytics

Chapter 7. Data Structures in R

Toward the end of Chapter 6 you learned how to work with packages in R. It’s common to load any necessary packages at the beginning of a script so that there are no surprises about required downloads later on. In that spirit, we’ll call in any packages needed for this chapter now. You may need to install some of these; if you need a refresher on doing that, look back to Chapter 6. I’ll further explain these packages as we get to them.

# For importing and exploring data
library(tidyverse)

# For reading in Excel files
library(readxl)

# For descriptive statistics
library(psych)

# For writing data to Excel
library(writexl)

Vectors

In Chapter 6 you also learned about calling functions on data of different modes, and assigning data to objects:

my_number <- 8.2
sqrt(my_number)
#> [1] 2.863564

my_char <- 'Hello, world'
toupper(my_char)
#> [1] "HELLO, WORLD"

Chances are, you generally work with more than one piece of data at a time, so assigning each to its own object probably doesn’t sound too useful. In Excel, you can place data into contiguous cells, called a range, and easily operate on that data. Figure 7-1 depicts some simple examples of operating on ranges of both numbers and text in Excel:

Typical ranges in Excel
Figure 7-1. Operating on ranges in Excel

Earlier I likened the mode of an object to a particular type of shoe in a shoebox. The structure of an object is the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Product Analytics: Applied Data Science Techniques for Actionable Consumer Insights

Product Analytics: Applied Data Science Techniques for Actionable Consumer Insights

Joanne Rodrigues
Advanced Analytics with PySpark

Advanced Analytics with PySpark

Akash Tandon, Sandy Ryza, Uri Laserson, Sean Owen, Josh Wills

Publisher Resources

ISBN: 9781492094333Errata Page