0
0
R Programmingprogramming~10 mins

R Console and script files in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print "Hello, world!" in the R console.

R Programming
print([1])
Drag options to blanks, or click blank then click option'
AHello, world!
B"Hello, world!"
Cprint("Hello, world!")
DHello
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text.
Putting the whole print statement inside print().
2fill in blank
medium

Complete the code to assign the number 10 to a variable named x.

R Programming
x [1] 10
Drag options to blanks, or click blank then click option'
A=
B==
C<-
D->
Attempts:
3 left
💡 Hint
Common Mistakes
Using == which is for comparison, not assignment.
Using = which works but <- is preferred style.
3fill in blank
hard

Fix the error in the code to correctly run a script file named "script.R".

R Programming
source([1])
Drag options to blanks, or click blank then click option'
A"script.R"
Bscript
Cscript.R
D'script.R'
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting the filename in quotes.
Using the filename without extension.
4fill in blank
hard

Fill both blanks to create a vector of numbers from 1 to 5 and print it.

R Programming
numbers <- [1]([2])
Drag options to blanks, or click blank then click option'
Ac
B1:5
Cseq
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using seq without parameters.
Not using c() to create a vector.
5fill in blank
hard

Fill all three blanks to read a CSV file named "data.csv", assign it to a variable, and print the first rows.

R Programming
[1] <- read.csv([2])
head([3])
Drag options to blanks, or click blank then click option'
Amy_data
B"data.csv"
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting filename in quotes.
Using different variable names inconsistently.