
Mastering R Programming Basics

Quiz
•
Others
•
University
•
Medium
krishan425 krishan425
Used 3+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the syntax for an if statement in R?
if (condition) code_to_execute else code_to_execute_if_false
if (condition) { code_to_execute } else { code_to_execute_if_false }
if { condition } then { code_to_execute }
if condition { code_to_execute }
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you write an if-else statement in R?
if (condition) { code_if_true } else code_if_false
if (condition) { code_if_true } else { code_if_false }
if condition { code_if_true } else code_if_false
if (condition) code_if_true else { code_if_false }
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What function is used to check multiple conditions in R?
ifelse() or case_when()
for()
switch()
repeat()
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the purpose of the switch statement in R.
To define a function in R.
To declare variables in R.
To create a loop in R.
The purpose of the switch statement in R is to select and execute code based on the value of an expression.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between for loop and while loop in R?
For loop is used for conditional execution; while loop is for fixed iterations.
For loop requires a condition to start; while loop does not need any condition.
For loop can only iterate over vectors; while loop can iterate over any data type.
For loop iterates a fixed number of times; while loop continues based on a condition.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you create a for loop to iterate over a vector in R?
foreach (i in my_vector) { print(i) }
for (i in my_vector) { print(i) }
for (i = 1; i <= length(my_vector); i++) { print(my_vector[i]) }
for (i in 1:length(my_vector)) { print(i) }
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code: for(i in 1:5) { print(i) }?
-1
1 2 3 4 5
6
0
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
LEA 4 FEBUARY 7, 2025

Quiz
•
University
20 questions
NUMBER THEORY AND CRYPTOGRAPHY QUIZ

Quiz
•
University
15 questions
Soal Grafem dalam Bahasa Indonesia

Quiz
•
University
15 questions
TFN PREFINALS REVIEWER

Quiz
•
University
17 questions
Rumus Penalaran Umum

Quiz
•
University
15 questions
Nervous Tissue Quiz

Quiz
•
University
15 questions
Calculus Teaching Quiz

Quiz
•
University
16 questions
Correlation & Regression Skills

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Others
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University