Introduction to R — Data Science Day 205

Michael M Hansen
Vizneo Academy
Published in
3 min readDec 21, 2022

--

The R logo. Source: https://www.r-project.org/logo/

R is a programming language and software environment for statistical computing and graphics. It is widely used by statisticians, data scientists, and analysts to explore, analyze, and visualize data. It has a large and active community of users and developers who contribute to its development and create packages to extend its capabilities.

R has a strong focus on statistical analysis and graphical representation of data. It has many built-in functions for performing standard statistical tests and plotting various graphs. It also has an extensive collection of packages that provide additional statistical and graphical tools and tools for machine learning, data manipulation, and more.

To use R, you need to install it on your computer and then open it in an R compiler or R IDE (Integrated Development Environment). R is a command-line-based language, meaning you will be typing commands and programming code into a text editor rather than using a graphical user interface. However, several graphical user interfaces are also available, making using R and its packages easier.

You can install R from the r-project website. The course: Introduction to R Programming by Simona Dobreva provides a great introduction to R and the use of Rstudio, with an IDE for R. You can download and install Rstudio from the new website posit.co, and find additional instructions here.

Rstudio example screen. Source: https://www.rstudio.com/blog/rstudio-1-4-a-quick-tour/

When you launch Rstudio, You will be greeted with a window with several panes. The top left pane is the console, where you can type in R commands and see their output. The top right pane shows the workspace and history of your R session. The bottom left pane has tabs for the files, plots, and packages you are working with. The bottom right pane has a help tab where you can search for documentation and examples.

To create a new script, go to the top left pane and click on the “File” menu. Then, select “New File” and choose “R Script.” This will open a new script window in the top left pane, where you can type in your R code.

To run a script, you can either highlight the code you want to run and press “Ctrl+Enter,” or click on the “Run” button in the top toolbar. You can also run individual lines of code by highlighting them and pressing “Ctrl+Enter.”

To view the output of your code, you can either look in the console pane or use the “Plots” tab in the bottom left pane to view the graphical output.

Authors image

You can save your scripts by going to the “File” menu and selecting “Save” or “Save As.” You can save your workspace by going to the “Workspace” menu and selecting “Save Workspace.”

RStudio has many other features, such as code completion, debugging tools, and integration with version control systems like Git. You can explore these features by clicking on the various tabs and menus in the program.

As you may have noticed from the images, to assign a value to a variable, R is different than Python, for example, as you assign a value with the following notation:

variablename <- 10
variablename. # is a comment

You can add comments using the # character followed by the comment text.

… More to come

--

--

Michael M Hansen
Vizneo Academy

Smart City and Urban Innovation: Interest in Digital Transformation, Design Thinking, Data Science and Open Source Solutions.