Everything is an object
The sooner you learn this, the fewer headaches you'll have in the future.
👋 The Core Ideas series uses data and code that you can get from this GitHub repo. Feel free to copy, test, adapt, and expand the code for your own projects 👍
The most basic idea you need to learn is that most of the things you want to interact with in R
are objects. If you have R
open right now, I bet you're working with data, a chart, or a table. Each one of these things is an object, which means you can save them, modify them, explore them, etc.
This is the main difference between using R
and using other software (Excel, SPSS, STATA, etc.) When you use R
, you need to be aware of what is an object, what is a function (that performs an action or a series of actions on objects), and how to work with your object.
While you may already know how to save, modify or explore some of these objects in R
, one can always learn new things that make the workflow more efficient. Trust me, after years of using R
frequently, I'm still learning things that improve my workflow.

The most typical object: A data frame.
In R
, the object you’ll interact with most of the time is a data frame (or df
for short). If you are getting started in R
, I bet that you’ve felt stuck a few times trying simple actions, such us importing data efficiently. Simple actions are so easy in other software, yet they feel like a heavy lift in R
😮💨.
Here, I want to go over the essentials:
There are many ways of reading (importing) and writing (exporting) data in
R
because many libraries or packages have their own functions to achieve the same goal. I prefer to keep things simple and rely on {tidyverse} functions to read (and clean) data most of the time.
# 1. Libraries & Data --------------------------------------
library(tidyverse)
# data
core_data <- read_csv("data/core_data.csv")
Here, we use read_csv()
to read a CSV file and we name the resulting object core_data
(You can find the full script here).
When you read (import) or write (export) data, you need to specify a path (location) to a file in your computer. Across examples in compañero, you’ll notice that I read data from a folder named “data”, which is in a folder named “Core Ideas.” These folders are the same folders in my Core Ideas GitHub repo.
Once you execute the function, you’ll see the object in your Global Environment tab. This is like a virtual copy of your data file. So, if you manipulate this object, the changes will not be reflected in your data file. Unless, of course, you overwrite the original file with your modified object.
summary()
allows you to see the structure of yourdf
. This function can also be used for other objects. For example, it can show you the summary output of a model.
Here, summary()
is showing us the variables in our df
. For numerical variables, the function describes their distribution (min and max values, median, etc.), whereas for categorical variables (here represented as character vectors), the function only describes their length and class.
🤔 Do you have any questions about the basics of reading and writing data frames? Let me know in the comments! 👇