Contents:

Free Python Course ➞ Mini-course for beginners and for Experienced coders. 4 cool projects in the portfolio, live communication with the speaker. Click and find out what you can learn in the course.
Learn moreThe R programming language is one of Python's main competitors in the field of statistics and data analysis. It is widely used in the social and economic sciences to identify causal relationships, compare samples, and create visual reports and graphs. Thanks to a rich ecosystem of packages and libraries, R allows for efficient data processing and visualization, making it an indispensable tool for specialists in this field.
The programming language was created by scientists from the Department of Statistics at the University of Auckland. Initially used as an internal tool, it has since become available to a wider audience due to its high efficiency and functionality. This language has quickly gained popularity among developers and researchers, demonstrating its success and usefulness across a variety of fields.
R is a powerful programming language created by statisticians for statisticians. It includes a wide range of popular statistical tests and data analysis methods, and offers convenient tools for data visualization through graphs. These features make R a unique tool not always available in other general-purpose languages. Its focus on statistics and data analysis makes R indispensable in research and analytical projects, ensuring accuracy and efficiency in data processing and interpretation.
The specialized R language has consistently occupied its niche in the programming world: from 18th place in the TIOBE ranking in 2016, it rose to 8th place in January 2021. You can install the interpreter and configure the working environment on any modern operating system, including macOS, Linux, and Windows. This makes R an accessible tool for analysts, statisticians, and data scientists worldwide.
What's Under the Hood
R is an interpreted, object-oriented programming language. This means that functions and tables in R are treated as objects belonging to certain classes (data types). Programs in this language are executed directly, line by line, without the need for preliminary compilation into an executable file. This approach simplifies the process of developing and debugging code, allowing users to quickly test and modify programs in real time. R is widely used in statistical analysis, data visualization, and scientific computing, making it a popular choice among analysts and researchers.
R's syntax is simple and includes basic primitive data types, such as character, numeric, logical, and complex. These primitive types can be combined into more complex structures. For example, a vector is a list containing multiple objects, such as numbers, strings, and other elements. Numeric variables in R can also have special values, including NaN (not a number), Inf (infinity), and NA (not available). Understanding these data types and their properties is key to effectively using the R language in data analysis and statistics.
Reading files is one of the most commonly used commands in R, as it is an essential step for data analysis and working with datasets. To successfully open and explore data, use the following command:
The data variable is used to store data from the file, and the assignment operator specifies that the value returned by the read.csv function will be saved in this variable. The read.csv function is designed to read files in the .csv format, and the sep parameter specifies the type of separator used in the source file (in this case, a comma). Correctly setting this parameter is important for the correct display of data in the table.
In addition to the command-line interface, graphical user interfaces and interactive tools are available for the R programming language. These tools significantly simplify working with R and make the process more enjoyable. They are available free of charge and distributed under the GNU GPL license. Let's consider the most popular of them.
- RStudio development environment. It can be installed on Windows, Linux, and MacOS. RStudio features visual R code highlighting, easy navigation through program text, edit history, sorting of table data by columns, displaying graphs in a separate window—in short, everything a normal development environment should have.

- Jupyter Notebook web interface. This is a notebook application for creating and sharing programs in R and many other languages that allow you to work with data. It opens in a browser, simultaneously displaying code and graphical elements - pictures, equations.
- The Anaconda distribution is a whole collection of popular libraries and programs for convenient work with data in the R language. By the way, there is also a version for Python, which is conveniently installed from a single file and includes RStudio, the Jupyter Notebook web interface and many other applications.
What can you do with R
- Process, clean and transform data for research. For example, you want to see how many users, on average, downloaded your mobile app for each summer and fall month. R allows you to exclude winter and fall from the graph and group them by month for further calculations.
- Run statistical tests. Let's say you want to find out if the average life expectancy differs between men and women. To do this, you can run a t-test - its results will show whether there are statistically significant differences between the data.
- Run exploratory analysis. The data must be checked for normality because many statistical methods (for example, the t-test) require a normal distribution in the source data. A normal distribution assumes that most of the data is grouped around the mean value, and the other values are much smaller. This distribution is often encountered in life: people of average height are the most common in the world, while tall and short people are rare. R has tools for checking normality using graphs and tests.

- Work with tables of different formats. This feature will be useful for analysts: for example, to combine data from several .csv and .xlsx tables and process them as a single file.
- Draw an interactive graph and adjust its parameters - axis values, and so on.
- Create an interactive application. The result is a nice-looking web page with a graph, filters, and data sorting. It can be sent to colleagues or published as part of an article. This is how coronavirus cases are tracked around the world (the code is open and available on GitHub).
- Analyze regression models. Regression analysis is a method that allows you to identify the relationship between dependent and independent variables. For example, an analyst wants to understand why sales are higher in some stores than in others. The dependent variable will be sales volume, and there are several independent variables - the income and age of residents in the area, and the distance from the store to bus stops. As a result, it's possible to determine which of these factors has the greatest impact on store revenue.
Numerous functions in R are included through libraries. The standard package includes approximately 20 libraries, such as stat for performing statistical tests and graphics for basic data visualization. Additional libraries can be downloaded from the CRAN server, which in 2020 contained over 16,000 packages. Notable among these are plotly, designed for creating interactive graphs, and tidyr, which simplifies the data cleaning process by allowing you to fill in missing values and ensure that each column corresponds to a single variable. These tools significantly expand R's functionality and make it a powerful tool for data analysis.
Comparing R with Other Data Tools
The main competitors of the R programming language include no-code data analysis tools such as Excel, Google Sheets, SPSS, Tableau, and Power BI. R also competes with other programming languages, including Python and Julia. These alternatives offer different approaches to data analysis and visualization, making the choice between them important for analytics professionals.
Python is a general-purpose programming language that allows for the development of a variety of applications. At the same time, R stands out for its powerful tools for statistical analysis, making it a preferred choice in the academic environment. Business analysts value both languages, but Python is currently more popular because it requires less effort to learn for beginners. Python offers a wide range of libraries and frameworks, making it ideal for solving a variety of problems, including data processing and machine learning. R, on the other hand, remains indispensable for research projects that require in-depth data analysis and visualization of results.
Proponents of the Julia programming language predict its status as a competitor to Python. However, Julia is still a relatively new language, which affects the size of its community. As a result, users face a lack of ready-made solutions, libraries, and documentation, especially in Russian.
An interesting thread on Reddit dedicated to choosing a programming language for analytics can be found. In our article, we take a detailed look at how to choose the right programming language that will be most effective for analytical tasks. We analyze various languages, their advantages and disadvantages, and their application in analytics. This will help you make an informed choice depending on your goals and requirements.
The strength of R and other programming languages lies in their high flexibility. Unlike programs such as Excel and Tableau, which have their limitations, R provides the ability to quickly create custom reports and graphs, as well as compare the necessary data. This is especially important when standard functions are insufficient. The R programming language also allows for efficient work with large volumes of data and the development of machine learning models, making it an indispensable tool for analysts and data scientists.
- Unlimited data analysis functionality thanks to library integration.
- Work with huge tables and databases that programs can't handle.
- Advanced interface options: graphical user interface or command line interface.
- Completely free ecosystem - components are distributed free of charge under the GNU license. Excel costs $69.99 per year, SPSS - $3,200 for a perpetual license, Tableau for enterprises - from $70 per user per month.
- Available for most operating systems: Windows, macOS, FreeBSD, Solaris, various versions of Unix and Linux.
- Rich visualization capabilities: you can create applications, build different types of graphs, including interactive ones, and edit their elements. For example, a graph based on the well-known iris dataset, showing the density of petals and sepals depending on the type of iris.

- Lots of information and an active community: blog, R and RStudio discussion, lessons, conferences.
- Extensive and Clear documentation: There are descriptions of all the libraries and usage examples. For example, here are materials on the dplyr library, which is used for processing and grouping data.
Are there any downsides to R?
The downsides of using the R programming language are relative and depend on specific tasks and context. Although R has powerful tools for statistical analysis and data visualization, it does have its drawbacks. First, R's performance can be slower compared to other languages such as Python or C++, especially when working with large amounts of data. Second, the R package ecosystem can sometimes be less diverse and updated than in other languages. Additionally, the language can be more difficult for beginners to master, as the syntax and concepts may differ from more common programming languages. Finally, R is less widely used in industry than other languages, which can limit career opportunities for those who only speak it.
- Documentation and most resources are in English only. However, more and more Russian-language resources are appearing—there's already a dedicated section on Habr, and answers to frequently asked questions can be found on Stack Overflow.
- It will be difficult for someone without programming experience and a basic understanding of statistics. However, mastering the basic concepts is sufficient: mean, mode, median, sample, and normal distribution. For example, from the book "Statistics and Cats" by V. Saveliev.
- It has a narrow scope of application: it's ideal for data analysis, but not suitable for software development. But that's also its strength. The real UNIX way and a godsend for scientists, journalists, data scientists, analysts—anyone who wants to work with data.

