I installed open-source R and found it to be surprisingly fun. Typing code, running the scripts through a console, and watching the output illuminate the screen is surprisingly thrilling.
Installing R and R Studio
Before you can use R Studio, you need to install R itself. Below are the steps to install R:
Go to the R project website at https://cran.r-project.org/.
Choose the version that corresponds to your operating system (Windows, Mac, or Linux).
Follow the installation instructions for your chosen operating system.
After installing R, you should install R Studio, which is an integrated development environment (IDE) for R:
Go to the R Studio website at https://www.rstudio.com/.
Click on the "Download" button.
Under "Installers for Supported Platforms," choose the version that corresponds to your operating system.
Follow the installation instructions.
Customizing R Studio
To begin, customize your text editor to a dark mode setting 😎
--->Global Options --->Appearance--->Editor theme--->Dracula.
In RStudio, the four main windows are:
Source Editor: This window is where you write and edit your R code. It provides features like syntax highlighting, code autocompletion, and indentation to help you write code efficiently. You can also execute individual lines or sections of code directly from the editor.
Console: The console is where you interact with R directly. It displays the results of your R code, including output, error messages, and warnings. You can type commands directly into the console and see their output immediately. It is also useful for experimenting with code and running ad-hoc analyses.
Environment/History/Connections/Tutorial: This window is a multi-panel window that displays different tabs, allowing you to explore various aspects of your R session. The Environment tab shows your current variables and their values, the History tab shows the commands you have executed
Files/Plots/Packages/Help/Viewer: The Files tab provides a file browser for navigating your file system, the Plots tab displays any plots you create, and the Packages tab shows the installed packages and allows you to manage them.This window also provides access to R's documentation and other reference materials. The Help tab displays help documentation for R functions and packages, while the Viewer tab can be used to view web-based content or HTML reports generated within R.
Writing Your First R Script
Now that you have R and R Studio installed, let's write your first R script. Don't worry; you don't need to be an expert in coding. R Studio makes it easy even for beginners.
Open R Studio.
Go to File > New File > R Script.
In the new script tab, type in the following code:
Save the script by clicking File > Save or by pressing Ctrl+S (Command+S on Mac).
Run the script by clicking the "Run" button or by pressing Ctrl+Enter (Command+Enter on Mac).
# This is a comment
print("Hello, World!")
This simple script just prints "Hello, World!" to the console. The line starting with a # is a comment and is not executed.
Resources:
Chang, W. (2020). R Graphics Cookbook, 2nd Edition. O'Reilly Media. https://r-graphics.org/
The R Project for Statistical Computing. (n.d.). Retrieved June 21, 2023, from https://www.r-project.org/
Wickham, H., & Grolemund, G. (2016). R for Data Science. O'Reilly Media. https://r4ds.had.co.nz/
David Langer. (2014, November 2). R Programming for Beginners - Part 1: Hello, World! [Video]. YouTube. https://www.youtube.com/watch?v=_V8eKsto3Ug
R Programming 101. (2022, January 10). R programming in one hour - a crash course for beginners [Video]. YouTube. https://www.youtube.com/watch?v=eR-XRSKsuR4
Kommentare