This lesson is in the early stages of development (Alpha version)

Introduction to R and RStudio

Overview

Teaching: 10 min
Exercises: 0 min
Questions
  • Why should I learn R?

  • How are R and RStudio related?

Objectives
  • Explain how R and RStudio relate to each other and what they are used for.

FIXME

What is R? What is RStudio?

The term “R” is used to refer to both the programming language and the software that interprets the scripts written using it.

RStudio is currently a very popular way to not only write your R scripts but also to interact with the R software. To function correctly, RStudio needs R and therefore both need to be installed on your computer.

Why learn R?

R does not involve lots of pointing and clicking, and that’s a good thing

The learning curve might be steeper than with other software, but with R, the results of your analysis do not rely on remembering a succession of pointing and clicking, but instead on a series of written commands, and that’s a good thing! So, if you want to redo your analysis because you collected more data, you don’t have to remember which button you clicked in which order to obtain your results; you just have to run your script again.

Working with scripts makes the steps you used in your analysis clear, and the code you write can be inspected by someone else who can give you feedback and spot mistakes.

Working with scripts forces you to have a deeper understanding of what you are doing, and facilitates your learning and comprehension of the methods you use.

R code is great for reproducibility

Reproducibility is when someone else (including your future self) can obtain the same results from the same dataset when using the same analysis.

R integrates with other tools to generate manuscripts from your code. If you collect more data, or fix a mistake in your dataset, the figures and the statistical tests in your manuscript are updated automatically.

An increasing number of journals and funding agencies expect analyses to be reproducible, so knowing R will give you an edge with these requirements.

R is interdisciplinary and extensible

With 10,000+ packages that can be installed to extend its capabilities, R provides a framework that allows you to combine statistical approaches from many scientific disciplines to best suit the analytical framework you need to analyze your data. For instance, R has packages for image analysis, GIS, time series, population genetics, and a lot more.

R works on data of all shapes and sizes

The skills you learn with R scale easily with the size of your dataset. Whether your dataset has hundreds or millions of lines, it won’t make much difference to you.

R is designed for data analysis. It comes with special data structures and data types that make handling of missing data and statistical factors convenient.

R can connect to spreadsheets, databases, and many other data formats, on your computer or on the web.

R produces high-quality graphics

The plotting functionalities in R are endless, and allow you to adjust any aspect of your graph to convey most effectively the message from your data.

R has a large and welcoming community

Thousands of people use R daily. Many of them are willing to help you through mailing lists and websites such as Stack Overflow, or on the RStudio community.

Not only is R free, but it is also open-source and cross-platform

Anyone can inspect the source code to see how R works. Because of this transparency, there is less chance for mistakes, and if you (or someone else) find some, you can report and fix bugs.

The Learning Process

Programming is hard. Not only is there a steep technical learning curve, but there is a lot of jargon that makes the initial learning curve difficult. Learning to program is a roller coaster ride

Programming itself involves breaking down your steps into small linear pieces. Do not try to do all of your analysis in a single step, and usually when you get stuck for a while, a simple walk to clear your head may be all you need to successfully approach the problem.

Debugging can be both frustrating and elating

There is a huge community of users, learners, and instructors that all want you to succeed.

There is a lot of support in the R community

The main take away is to learn about formatting your data set, and planning how your data sets may be useful in the future. When you are starting to learn how to program, you do not need to jump into it completely, if this book shows you a technique that makes your data pipeline easier, there is nothing wrong with writing the few lines of code to read in, manipulate, and save out the dataset for something else. Your programming skills will build over time, and there is no need to rush it.

Learning to program happens over time

Key Points

  • First key point. Brief Answer to questions. (FIXME)