Mastering R Programming Basics

Mastering R Programming Basics

University

20 Qs

quiz-placeholder

Similar activities

Future simple, continuous and perfect

Future simple, continuous and perfect

University

20 Qs

Quiz 03 - Spiritual Self

Quiz 03 - Spiritual Self

University

20 Qs

A quiz on personality

A quiz on personality

University

15 Qs

Quiz on Flexible Learning and Instructional Delivery

Quiz on Flexible Learning and Instructional Delivery

University

15 Qs

G12

G12

University

20 Qs

Unit4: Trends!

Unit4: Trends!

University

15 Qs

Economics Quiz on Production Concepts

Economics Quiz on Production Concepts

University

20 Qs

Final Exam Reviewer

Final Exam Reviewer

University

20 Qs

Mastering R Programming Basics

Mastering R Programming Basics

Assessment

Quiz

Others

University

Practice Problem

Medium

Created by

krishan425 krishan425

Used 3+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?