Data files and data frames

Last chapter we learned about vectors: sequences of numbers or strings. But if you ever worked with data, you know that data usually doesn’t get e-mailed to you as a vector, it comes as a table or spreadsheet. Tables are also the most common way to work with data in R, and in this chapter we’ll learn more about that.

The first thing we’ll learn is that, in R, tables are called data frames. There’s many ways to create data frames and one basic way is to stick some vectors in the data.frame() function. For example, data.frame(x, y, z) would create a data frame that included the data from vectors x, y, and z as columns.

Replace the ______ placeholder with a data frame with columns quarter, revenue, and expenses and assign it to the variable finances. Then, press ▶ Run Code.
quarter = c("Q1", "Q2", "Q3", "Q4")
revenue <- c(120, 150, 78, 104)
expenses <- c(106, 112, 96, 98)
finances <- ______
_webr_editor_1 = Object {code: null, options: Object, indicator: it}
Downloading package: tidyverse