Recall & Review
beginner
How do you run a single line of R code in the R console?
You type the line of code and press Enter. The R console then executes the code and shows the result.
Click to reveal answer
beginner
What is the purpose of the
source() function in R?The
source() function runs all the R code saved in a file. It helps you run scripts instead of typing code line by line.Click to reveal answer
beginner
What happens when you run
print("Hello, world!") in R?R shows the text Hello, world! in the console. The
print() function displays the message on the screen.Click to reveal answer
beginner
How can you run multiple lines of R code at once in RStudio?
You select the lines you want to run and press Ctrl+Enter (Cmd+Enter on Mac). This sends the selected code to the console to run together.
Click to reveal answer
beginner
What is the difference between running code in the R console and running code in an R script file?
Running code in the console executes one line at a time immediately. Running code in a script file lets you save many lines and run them all at once or in parts.
Click to reveal answer
Which function runs all the R code saved in a file?
✗ Incorrect
The
source() function runs all the R code saved in a file.How do you run selected lines of code in RStudio?
✗ Incorrect
Selecting lines and pressing Ctrl+Enter (Cmd+Enter on Mac) runs the selected code in RStudio.
What does the
print() function do in R?✗ Incorrect
The
print() function shows the given message or value in the console.What happens when you press Enter after typing code in the R console?
✗ Incorrect
Pressing Enter runs the typed code immediately and shows the output.
Which is true about running code in an R script file?
✗ Incorrect
An R script file lets you save and run many lines of code together.
Explain how to run R code using the console and using a script file.
Think about immediate execution vs saved scripts.
You got /3 concepts.
Describe how you can run multiple lines of code at once in RStudio.
Focus on keyboard shortcuts and selection.
You got /3 concepts.