2.5 What is R?
What is R? This question can be answered several different ways. Here are a few of them:
2.5.1 R is a Programming Language
A programming language is a way of providing instructions to a computer. Some popular languages (in no particular order) are C, C++, Java, Python, PHP, Visual Basic, and Swift. Much like other types of languages, programming languages combine text and punctuation (syntax) to create statements which provide meaningful instructions (semantics) to be performed by a computer. These instructions are called “code”. R code can be used to do many things, but primarily R was designed to easily work with data and produce graphics. The R language can be used to get a computer to do the following:
- Read and process a set of data in a file or database
- Use data to compute statistics and perform statistical tests
- Produce nice looking visualizations of data
- Save data for others to use. But this list is just the tip of the iceberg. As you will see, R can be used to do so much more! After the instructions are written, the R code is run, that is, the code is provided to the computer, and the computer performs the instructions to produce the desired results.
Many other programming languages use different syntax for the same purpose.
#
comments out a line in
R and python
%
comments out a line in
matlab
//
comments out a line
in C++ and javascript
Similar to learning a foreign language, learning your first programming language will make it easier to understand other similar ones.
2.5.2 R is software
R can also be thought of as the software program which runs R code. In other words, if R code is the computer language, then the R software is what interprets the language and makes the computer follow the instructions laid out in the code. This is sometimes called “base R”.
2.5.3 R is Free
The R software is free, so anyone can download R, write R code, and run the R code in order to produce results on their computer.
2.5.4 R is Open Source
The R software, which runs R code, is also made up of a bunch of code called source code. In addition to being free, R is also open source, meaning that anyone can look at the source code and understand the “deep-down nuts-and-bolts” of how R works. In addition, anyone is able to contribute to R, in order to improve it and add new features to it.
What are the advantages of open-source software? What are some potential downsides?
Why do you think the creators of R decided to make it open source?
2.5.5 R is an ecosystem
Another way of thinking about R is to include not only the R language and the R software, but also the community of R users and programmers, and the various “add on” software they have created for R. These add on software are called “packages”.
2.5.6 R Packages
An R package is software written to extend the capabilities of base R. R packages are often written in R code, so anyone who knows how to write R code can also create R packages. The importance of packages cannot be understated. One of the reasons for the incredible popularity of R is the fact that members from the community can write new packages which enable R to do more. Sometimes packages are written to help folks in particular disciplines (e.g. psychology, geosciences, microbiology, education) do their jobs better. Other times, packages are written to extend the capability of R so that people from many disciplines can use them. R can be used to make web sites, interactive applications, dynamic reproducible reports, and even textbooks (like this one!).
The inclusion of R packages, combined with the free and open source nature of R software, has led to the development of an active, diverse, and supportive community of R users who can easily share their code, data, and results with one another.
skimr is one example of a package. It provides a frictionless approach to summary statistics which conforms to the principle of least surprise, displaying summary statistics the user can skim quickly to understand their data.
2.5.7 R Interfaces
The R software can be run in many different places, including personal computers, remote servers, and websites (as you have seen!). R works on Windows, macOS, and Linux, and R can be run using a terminal or command line (if you know what those are), or using a graphical user interface (with buttons you can click and such). By far one of the most popular ways of using R is with RStudio, which is also free and open source software. For this course, you’ll be using RStudio.
Any feedback for this section? Click here