RStudio is an Integrated Development Environment (IDE) for R
RStudio is an Integrated Development Environment (IDE) for R
Easier working with R
More information
First it is important to be familiar with the layout. When you first open RStudio, you will see 3 panes.
If RStudio doesn’t look the way you want (or like our RStudio), then:
Click on the pane button, which looks like a waffle with 4 indentations. Scroll down to “Pane Layout”.
More on this in a moment!
In a .R file (we call a script), code is saved on your disk
Super useful “cheat sheet”: https://github.com/rstudio/cheatsheets/raw/master/rstudio-ide.pdf
It will look like this with text in it, unlike a script.
Although people will use scripts often, and they are good for more programmatic purposes, we generally don’t recommend them for data analyses.
R Markdown files are generally superior because they allow you to check your code and write more info about your code.
object: an object is something that can be worked with or on in R - can be lots of different things! You can think of objects as nouns in R.
… many more
History
R Markdown files (.Rmd) help generate reports that include your code and output. Think of them as fancier scripts.
Go to File → New File → R Markdown or click the green add file button.
Within R Markdown files are code “chunks”.
This is where you can type R code and run it!
Clicking the run (play) button runs the code in the chunk.
Ctrl + Enter
on Windows or Command + Enter
on Mac in your script evaluates that line of code
Running all chunks - this will create a report from the R Markdown document!
This generates a nice report that you can share with others who can open in any browser.
To create a new R code chunk:
You can run all chunks above a specific chunk using this button:
You can specify if a chunk will be seen in the report or not.
R studio can help you find issues in your code. Note that sometimes the error occurs earlier than RStudio thinks.