Search Header Logo

Programming R Quiz

Authored by David Eng

Special Education

11th Grade

Used 11+ times

Programming R Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the function `install.packages()` do in R?

It updates installed packages to the latest version.

It installs new R packages from CRAN.

It lists all available packages in CRAN.

It removes specified packages from the system.

Answer explanation

The function 'install.packages()' in R installs new R packages from CRAN, making it the correct choice among the options provided.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which function is used to read a CSV file in R?

read.csv()

read_excel()

open.csv()

file.open()

Answer explanation

The correct function to read a CSV file in R is read.csv()

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a vector in R containing the numbers 1 through 5?

c(1:5)

vector(1, 5)

list(1-5)

sequence(1, 5)

Answer explanation

To create a vector in R containing the numbers 1 through 5, you use the syntax c(1:5), which generates a sequence from 1 to 5.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What symbol is used to assign a value to a variable in R?

=

:=

<-

==

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a way to generate a sequence of numbers from 1 to 10 in steps of 2 in R?

seq(1, 10, by=2)

sequence(1, 10, 2)

1:10+2

c(1, 3, 5, 7, 9)

Answer explanation

The correct way to generate a sequence of numbers from 1 to 10 in steps of 2 in R is by using the 'seq(1, 10, by=2)' function.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you check the structure of a data frame named `df` in R?

structure(df)

str(df)

typeof(df)

describe(df)

Answer explanation

The correct way to check the structure of a data frame in R is by using the 'str(df)' function, which provides a concise summary of the data frame's structure.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code snippet? ```R x <- c(TRUE, FALSE, TRUE, FALSE) sum(x) ```

0

2

4

TRUE

Answer explanation

The sum of logical values in R treats TRUE as 1 and FALSE as 0. Therefore, sum(x) will result in 2.

Access all questions and much more by creating a free account

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

Already have an account?