Introduction to R
Overview
This unit provides a high‑level introduction to R.
Goals
- Understand what R is used for.
- Know some of the strengths and weaknesses of R.
Reading
Programming Languages
In brief, programming languages are ways to get a computer to do things. There are many different programming languages, each with its own syntax (rules for how to write code), strengths and weaknesses, and areas of application. Some programming languages are general-purpose, meaning they can be used for a wide range of tasks (e.g., Python, Java, C++). Others are more specialized, designed for specific tasks or domains (e.g., R for statistics, SQL for database queries).
For data-science-type work, there are several popular programming languages, including R, Python, Julia, and MATLAB. Each of these languages has its own strengths and weaknesses, and the choice of which one to use often depends on the specific needs of the project, the preferences of the team, and the existing ecosystem of tools and libraries.
The R language
R is a programming language and software environment specifically designed for statistical computing and graphics. It was created in the early 1990s by Ross Ihaka and Robert Gentleman at the University of Auckland in New Zealand. R has since become one of the most widely used languages for data analysis, statistical modeling, and data visualization.
R strengths and weaknesses
Like every programming language, R has its advantages and disadvantages. Feel free to do a web search on that topic, and you will encounter tons of people with tons of opinions. Some of the features that are useful to us are:
- R is Open Source, FREE, and cross-platform.
- R is a “high-level” programming language, relatively easy to learn (compared to Fortran, C, etc.).
- R comes with many integrated functions.
- R is great for statistics, data analysis, and graphics.
- The R Community is very dynamic, helpful and welcoming.
- Through R packages, it is easy to get lots of state-of-the-art algorithms.
- Documentation and help files for R are generally good.
While we use R in this course, it is not the only option for modeling and data analysis. Maybe the most similar to R, and widely used, is Python, which is also free. There is also commercial software that can be used to analyze data (e.g., MATLAB, Mathematica, Tableau, SAS, SPSS). Other more general programming languages can at times be suitable as well (e.g., C, Fortran, Perl, Java, Julia). Depending on your future needs or jobs, you might have to learn one or several of those additional languages. The good news is that even though those languages are all different, they all share general ways of thinking and structuring code. So once you understand a specific concept (e.g., variables, loops, branching statements or functions), it applies to all those languages. Thus, learning a new programming language is much easier once you already know one. And R is a good one to get started with.
Summary
This unit explained what R is and its strengths and weaknesses.
Further Resources
Since R is widely used, there’s a ton of information available. The official R website is actually not the best source for introductory documentation, but the Internet is full of tutorials on every aspect of R. Google will help you find information, and your favorite AI too can also either explain things to you, or even write code for you.
Test yourself
What is R primarily designed for?
R was built for statistical computing and graphics, which is why it is widely used for data analysis and visualization.
- False
- False
- True
- False
Which of the following is highlighted as a strength of R?
R is free, runs across platforms, and offers many packages and community support, making it strong for data analysis and graphics.
- True
- False
- False
- False
What general takeaway about learning programming languages is emphasized?
Once you learn foundational concepts (e.g., variables, loops, functions) they apply across languages, making it easier to pick up new ones.
- False
- False
- False
- True
Practice
- Look through the official R website to learn about the language. Read anything that sounds interesting to you.
- Ask your favorite AI to give you a quick overview of R, compare it to some other language you already know (if applicable), and provide you with any other R-related information you are curious about.