Data as Objects, Analysis as Transformation
bookOne :: chapter-1Data as Objects, Analysis as Transformation
In R, you don’t command the data — you transform it.
Every R session is a living stream. Data flows in, and with each pipe, it changes shape — cleaner, clearer, closer to insight.
That is the essence of R: data as objects, analysis as transformation.
🧩 Seeing Data as Objects
Everything in R is an object — data frames, vectors, lists, models.
You don’t just run commands; you manipulate structures.
This object orientation makes R a consistent and expressive tool.
# A tibble is more than a table — it’s an object with behavior
library(tibble)
df <- tibble(
species = c("Elephant", "Tiger", "Turtle"),
weight_kg = c(5400, 220, 90)
)
print(df)
Each column is a vector, each row a moment in your data’s story.
🔄 The Pipe: The Language of Flow
The pipe (|>, or %>% from magrittr) changed everything.
Instead of nesting functions, you think in transformations — one step flows into the next.
Kesulitan dengan riset atau tugas akademik Anda?
Tim ahli Notivra siap mendampingi Anda memberikan solusi bimbingan dan dukungan akademik yang komprehensif.
library(dplyr)
df |>
mutate(weight_ton = weight_kg / 1000) |>
filter(weight_ton > 0.1) |>
arrange(desc(weight_ton))
Each line reads like a sentence: “Take the data, then mutate, then filter, then arrange.”
It’s not programming — it’s thought in motion.
🧠 Transformation as Understanding
Transformation is not just cleaning — it’s modeling your mental structure of reality.
When you reshape a dataset, you’re deciding what matters, what disappears, and what stays visible.
In this way, analysis becomes an act of philosophy: how you choose to see the world.
💡 Reflection
What does your pipeline say about how you think?
Try this:
library(dplyr)
starwars |>
select(name, species, height, mass, homeworld) |>
mutate(bmi = mass / (height/100)^2) |>
arrange(desc(bmi)) |>
head(5)
This is not just code — it’s a thought process, rendered in syntax.
📘 Try It Yourself
- Take any dataset from
datasets:: - Apply at least three transformations using the pipe
- Observe how your mental model of the data changes
🔗 Further Reading
- Wickham, H. (2014). Tidy Data. Journal of Statistical Software.
- Bache & Wickham (2014). Magrittr: A Forward-Pipe Operator for R.
- Hadley Wickham’s Advanced R, Chapter 6: Functions.
In R, transformation is not a step — it’s the soul of the analysis.
Artikel Terkait
The Grammar of Data
Learn how to use dplyr—the grammar of data manipulation in R—to transform raw datasets into meaningful insights.
From Code To Insight
Numbers whisper. Models hum. But the real music begins only when you *listen*. R is not just a tool for data — it’s a language for seeing. Each transformation, each plot, each tidy frame is a translation of the world’s complexity into meaning.
Thinking in Vectors, Not Loops
R doesn’t iterate — it transforms. Understanding vectors is the key to writing expressive, efficient, and elegant R code.