0
0
R Programmingprogramming~5 mins

Running R code in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Asource()
Brun()
Cexecute()
Dload()
How do you run selected lines of code in RStudio?
APress Ctrl+S
BPress Ctrl+Enter (Cmd+Enter on Mac)
CPress Ctrl+R
DPress Ctrl+C
What does the print() function do in R?
AStops the program
BSaves the code to a file
CRuns a script file
DDisplays output in the console
What happens when you press Enter after typing code in the R console?
AThe code is saved but not run
BThe console clears
CThe code runs and shows the result
DThe program exits
Which is true about running code in an R script file?
AYou can run many lines at once
BYou can only run one line at a time
CIt does not show output
DIt only works in the console
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.