To the vast majority of Indian learners who enter the world of data analytics or research, R initially represents a promising place, a new frontier of cleaning, visualizing, and structuring data in an efficient way. However, frustration will come very quickly. The syntax is not consistent, the errors have no explicit explanations and nothing appears to work as it should. You could have mastered the R programming basics but you find that your code is still breaking without any obvious creative reason. In case this rings a bell, then you are not the only one. It is not about the intellect or hard work but about the way R is organized and is delivered in most of the Indian educational experiences.
The Real Reason why R Feels Different.
To know why R is unintuitive, it is useful to recollect the source of it. R is not really intended to be a general-purpose programming language, but rather a development of a statistical computing heritage. It implies that its logic lays more emphasis on data structures and analysis processes rather than procedural line by line thinking. To people with Excel or Python or C backgrounds, such a transition may seem like learning to write left-handed.
In R, data is not simply stored, it is transformed. The language is based on the idea of vectors, lists and data frames which do not act like the common arrays or tables. A vector of numbers is not identical to a single number, thus operations on them yield sets of results as a whole. Such abstraction is so strong and at the same time confusing when you are used to cell-by-cell manipulation. The trick is to no longer think of R as a calculator but consider it as an engine of data manipulation.
The Syntax Trap
One of the greatest frustrations to novices is the flexibility of the syntax of R. One may often do the same task in more than one way, subsetting data, writing functions, or plotting graphs. This may appear empowering but it can easily create confusion as to what is correct. As an example, similar result can be obtained with indexing with brackets [ ] or with functions such as subset() though each acts a bit differently. Such diversity is confusing to learners who anticipate having a single standardized method.
Furthermore, R can present vague error messages. Contrary to Python, which tends to provide elaborate tracebacks, R can just tell you, either, object not found, or, unexpected symbol, with no further explanation on what has happened. It is important to understand that R may presuppose that you know what type of object you are dealing with. Otherwise, mistakes seem arbitrary. The solution is to train yourself to first look at your data, with functions such as str, summary or class, and only then to act on it. As soon as you get used to it, the fog begins to clear.
Developing Intuition with Practice.
The instinctive response to hitting a wall is to seek shortcuts, templates, pre-written scripts or a tutorial. But the fact is R rewards knowledge rather than memory. The actual development occurs when you practice the fundamentals until they become part of you. Attempt to write little pieces of code which work with the same dataset in various forms. See how R responds to logical conditions, to missing values, mixing types of data. Such active experimentation lays the ideas much deeper than passive learning.
Another thing one should understand is that the structure of R promotes functional thinking. Most of the times instead of doing one task at a time you are chaining several commands together using pipes. As soon as you learn this concept, R programming basics can become a language of expressions of analytical reasoning - virtually, a kind of narration of your data.
From Frustration to Fluency
When these mental changes settle in, R is no longer difficult, but instinctive. That elasticity, the multi-layered syntax, the insistence on an understanding of objects, all those peculiarities with which I felt frustrated before, become resources that enable a deeper analysis. You start to recognize the beauty in the way in which the R formats data, automates reporting and visualizes patterns.
It is not about learning R programming basics fast and memorizing it, but rather internalizing the way R thinks. When you get in the right state of mind that the language is set up to be, all its concepts, vectors and data frames, fall together.
Sign in to leave a comment.