Back

Everything is a Function

I have used R for most of my work in analytics and even started teaching it some months ago, but I still largely feel like I don’t know what I am doing.

A mental model that has helped me stay on top of things is to think of everything as a function. Because in reality, everything you do in R is essentially calling a function, even when it doesn’t look like it. 

More correctly though, everything is an object, and the objects have classes, and Functions are objects whose class is “function”. 

But this rattles my brain, so I just summarily call everything a function. When you work with R, most of the operations you’ll carry out, are function calls library(), mutate(), ggplot() etc 

A lot of data analysis is data transformation and functions are how we describe transformation. So, instead of trying to ‘understand the Language’ I focused on three concepts: What goes in, what comes out, what transformations do I need? 

During my MSc, we did a course ‘Recent Topics in Data Science’.  It was a theoretical intro to machine learning. We were introduced to the topic of perceptrons, which was developed by Frank Rosenblatt, an American psychologist who made foundational contributions to AI. 

The perceptron was the first algorithm that could learn from data by adjusting weights. That’s the basic mechanism behind modern neural networks, including deep learning models and language models. 

It was a mathematical model of how neurons in the brain might process information. The basic perceptron works by taking multiple inputs (features), multiplying each input by a weight, summing these weighted inputs and applying a threshold function to produce a binary output (typically 0 or 1).

I did not understand it like this at the time, as I felt so overwhelmed by the other theorems and math surrounding them. 

I got a C *insert sad emoji*.

But I didn’t leave it alone, I found myself reviewing some of my lecture notes to help with work one time and It clicked to me that Rosenblatt’s perceptron was simply a mathematical function. It was always in front of me, input – transformation – output. But maybe the overwhelm of school made things more complex than they appeared.

He was telling us, intelligence itself is just a play of functions.

Once you start seeing through this lens, the pattern appears everywhere. You will come to see that even life follows this fundamental structure: DNA – proteins – traits. 

Input, transformation, output.