Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

R Language Quiz

Total questions: 111

Worksheet time: 56mins

Name
Class
Date
1.

In what year was Version 4 of the S language released, which is the version used today?

a)

1988

b)

1993

c)

1998

d)

2004

2.

Which company serves as the current owner and exclusive developer of the S language?

a)

Bell Labs

b)

StatSci

c)

Insightful Corp.

d)

TIBCO

3.

Among the following, identify an object class that is not considered one of the five basic or "atomic" classes in R.

a)

numeric

b)

string

c)

integer

d)

logical

4.

Which symbol functions as the assignment operator in R?

a)

=

b)

<-

c)

->

d)

+

5.

What is the sole character used to denote a comment in R?

a)

//

b)

/* */

c)

#

d)

--

6.

What fundamental rule governs the composition of vectors in R?

a)

A vector can contain objects of different classes.

b)

A vector can only contain objects of the same class.

c)

Vectors must always be explicitly initialized with vector().

d)

Vectors can only store numeric data.

7.

How does one explicitly designate an integer object in R (e.g., the number 1)?

a)

as.integer(1)

b)

integer(1)

c)

1L

d)

int(1)

8.

What does the value NaN signify in R?

a)

Negative infinity

b)

Not a number

c)

A null value

d)

A zero value

9.

Which R object type is described as a "special type of vector that can contain elements of different classes"?

a)

Matrix

b)

Data Frame

c)

Factor

d)

List

10.

When importing larger datasets using read.table(), what benefit arises from employing the colClasses argument?

a)

It ensures R reads the entire file by default.

b)

It prevents R from incorrectly guessing column types.

c)

It automatically sets the comment character.

d)

It speeds up the data writing process.

11.

What was the initial implementation of the S language at Bell Telephone Laboratories?

a)

C++ libraries

b)

Python scripts

c)

Fortran libraries

d)

Java applications

12.

In what year was the S system re-engineered in C, marking its progression to Version 3 and its current form?

a)

1993

b)

1988

c)

1998

d)

2006

13.

Which book, famously known as "the white book," documents the statistical analysis capabilities of S?

a)

Programming with Data

b)

The Art of R Programming

c)

Statistical Models in S

d)

Advanced R

14.

The book "Programming with Data" by John Chambers, recognized as "the green book," provides documentation for which version of the S language?

a)

Version 2

b)

Version 3

c)

Version 4

d)

Version 5

15.

How much did Insightful pay Lucent in 2004 to acquire the S language?

a)

$1 million

b)

$2 million

c)

$2.5 million

d)

$25 million

16.

Which highly esteemed award did S receive in 1998 within the computer science domain?

a)

Turing Award

b)

Nobel Prize in Computer Science

c)

Association for Computing Machinery's Software System Award

d)

IEEE John von Neumann Medal

17.

A defining characteristic of R in its early stages was its syntactic resemblance to which language, facilitating a smooth transition for S-PLUS users?

a)

Python

b)

Java

c)

S

d)

C++

18.

Although R's syntax mirrors S's, its underlying semantics are fundamentally closer to which language?

a)

Fortran

b)

Scheme

c)

C

d)

Pascal

19.

What fundamental philosophical aspect of S has R preserved, focusing on its utility for both interactive tasks and the creation of new tools?

a)

Closed-source development

b)

Proprietary licensing

c)

Open-source only tools

d)

A language useful for interactive work and powerful for programming new tools

20.

What is a significant advantage of using R, independent of the language itself?

a)

Its high performance for large datasets

b)

Its pre-built graphical user interfaces

c)

Its active and vibrant user community

d)

Its strict adherence to academic standards

21.

What is the primary source for the R system, also recognized as CRAN?

a)

R-Forge

b)

GitHub

c)

Comprehensive R Archive Network

d)

Bioconductor

22.

What foundational component resides in the "base" R system, essential for R's operation and containing its core functions?

a)

Only recommended packages

b)

The base package

c)

User-contributed packages

d)

All CRAN packages

23.

How many user-developed packages are approximately accessible on CRAN?

a)

Hundreds

b)

Over 4000

c)

Tens of thousands

d)

Fewer than 100

24.

What specific symbol is designated as the assignment operator in R?

a)

=

b)

==

c)

<-

d)

->

25.

What does the character # signify within R code?

a)

A string literal

b)

A code block

c)

A comment

d)

An operator for exponentiation

26.

Does R offer support for multi-line comments or comment blocks?

a)

Yes, using /* */

b)

Yes, using ``

c)

R only supports single-line comments with #.

d)

Yes, using ///

27.

When an expression is input at the R prompt, what action follows its evaluation?

a)

It is saved to a file.

b)

The R session is terminated.

c)

The result of the evaluated expression is returned.

d)

It is automatically converted to a function.

28.

What does [1] signify in the R output [1] 5?

a)

The value 1 is part of the vector.

b)

The output is from the first line of code.

c)

That x is a vector and 5 is its first element.

d)

It's an error message.

29.

By default, how does R generally categorize numbers?

a)

Integer objects

b)

Character objects

c)

Numeric objects (double precision real numbers)

d)

Complex objects

30.

To explicitly establish an integer object in R, which suffix should be appended to the number?

a)

D

b)

L

c)

I

d)

F

31.

What specific number in R denotes infinity, facilitating calculations like 1 / 0?

a)

NULL

b)

NA

c)

Inf

d)

Undefined

32.

Which operator facilitates the creation of integer sequences in R (e.g., 110)?

a)

-

b)

+

c)
d)

*

33.

What best describes the "attributes" of an R object?

a)

The data stored within the object

b)

The functions that operate on the object

c)

Metadata for the object

d)

The object's memory address

34.

Which function provides access to the attributes of an R object?

a)

get_attributes()

b)

attr()

c)

attributes()

d)

list.attributes()

35.

What function is commonly utilized to construct vectors by combining elements?

a)

concatenate()

b)

combine()

c)

c()

d)

vector()

36.

When diverse object classes are combined within a vector (e.g., c(1.7, "a")), what process ensures all elements share the same class?

a)

Error generation

b)

Automatic deletion of incompatible elements

c)

Coercion

d)

Conversion to a list

37.

What results from combining a numeric object with a character object in a vector (e.g., c(1, "a"))?

a)

A numeric vector with NA for the character.

b)

An error.

c)

A character vector.

d)

A logical vector.

38.

How can objects be explicitly transformed from one class to another in R, if such a conversion is supported?

a)

Using convert_to() functions

b)

Using change_class() functions

c)

Using as.* functions (e.g., as.numeric())

d)

Using the coerce() function

39.

What is the fundamental nature of matrices in R, with an additional characteristic?

a)

Lists with numeric elements

b)

Factors with dimensions

c)

Vectors with a dimension attribute

d)

Data frames with a single column

40.

How are matrices constructed by default in R?

a)

Row-wise

b)

Column-wise

c)

Diagonally

d)

Randomly

41.

Which functions facilitate the creation of matrices by binding columns or rows?

a)

bind_cols() and bind_rows()

b)

col_bind() and row_bind()

c)

cbind() and rbind()

d)

merge_cols() and merge_rows()

42.

What is a defining feature of lists concerning the variety of elements they can encompass?

a)

They can only contain numeric elements.

b)

They must contain elements of the same class.

c)

They can contain elements of different classes.

d)

They can only contain other lists.

43.

How can factors be conceptualized in R?

a)

As character vectors with numeric labels

b)

As integer vectors where each integer has a label

c)

As logical vectors with categorical names

d)

As complex numbers with predefined levels

44.

What advantage do factors with labels (e.g., "Male", "Female") offer over using integers (e.g., 1, 2) for categorical data?

a)

Factors are more memory efficient.

b)

Factors are self-describing.

c)

Factors can store more categories.

d)

Factors are faster for computations.

45.

Which function is utilized to generate factor objects?

a)

as.factor()

b)

make.factor()

c)

factor()

d)

create_factor()

46.

What argument within the factor() function allows for setting the specific order of a factor's levels?

a)

order

b)

levels

c)

labels

d)

sequence

47.

How does R denote missing values resulting from undefined mathematical operations?

a)

NULL

b)

Error

c)

NA or NaN

d)

Missing

48.

Which function serves to verify if objects are NA?

a)

is.null()

b)

is.na()

c)

test.na()

d)

check.na()

49.

Which function specifically identifies NaN values?

a)

is.na()

b)

is.nan()

c)

has.nan()

d)

test.nan()

50.

Is a NaN value considered NA?

a)

They are entirely distinct.

b)

Yes, but the reverse is not true.

c)

Only if it's a numeric NA.

d)

Only when explicitly coerced.

51.

What is a particularly valuable reason for assigning names to R objects?

a)

To make them faster to process.

b)

For writing readable code and self-describing objects.

c)

To reduce their memory footprint.

d)

To enable automatic type conversion.

52.

According to the document, what is the distinction in usage between names() and row.names() for data frames?

a)

names() is for row names, row.names() is for column names.

b)

names() is for column names, row.names() is for row names.

c)

Both names() and row.names() are for column names.

d)

Data frames only have row.names().

53.

How are data frames internally structured in R?

a)

As a special type of matrix.

b)

As a specialized type of vector.

c)

As a special type of list where every element has the same length.

d)

As a collection of atomic classes.

54.

What is a key difference between data frames and matrices concerning the classes of objects they can store?

a)

Matrices can store different classes, data frames cannot.

b)

Data frames can store different classes in each column, while matrices require all elements to be of the same class.

c)

Both data frames and matrices can store different classes.

d)

Neither can store different classes.

55.

What function is typically employed to create data frames by importing a dataset?

a)

create.dataframe()

b)

load.data()

c)

read.table() or read.csv()

d)

dataframe()

56.

What is the specific function of readLines?

a)

For reading tabular data.

b)

For reading individual lines from a text file.

c)

For reading in R code files.

d)

For reading saved workspaces.

57.

What is the purpose of the dget function?

a)

For writing tabular data.

b)

For reading R objects from a file (the inverse of dput).

c)

For saving R objects in binary format.

d)

For converting an R object to binary.

58.

What is the function of write.table?

a)

For writing character data line-by-line.

b)

For dumping a textual representation of multiple R objects.

c)

For saving arbitrary R objects in binary format.

d)

For writing tabular data to text files (e.g., CSV).

59.

What is the default comment.char setting in read.table()?

a)

*

b)

//

c)

#

d)

--

60.

If your file contains no commented lines, what value is advisable to set for comment.char in read.table()?

a)

NULL

b)

NA

c)

The empty string ""

d)

.

61.

What is a significant advantage of utilizing the colClasses argument in functions like read.table() for large files?

a)

It increases the number of rows read.

b)

It notably accelerates the data reading process.

c)

It automatically handles missing values.

d)

It converts all strings to factors.

62.

What is the approximate memory footprint for a data frame comprising 1,500,000 rows and 120 numeric columns, assuming each numeric value occupies 8 bytes?

a)

144 MB

b)

1.34 GB

c)

14.4 GB

d)

134 MB

63.

What common undesirable situation can arise when attempting to import a large dataset into R without sufficient RAM?

a)

R automatically compresses the data.

b)

R spills data to disk, slowing down.

c)

Your computer (or at least your R session) may freeze.

d)

R automatically scales down the dataset.

64.

Which R operator consistently yields an object of the same class as the original during subsetting?

a)

[[

b)

$

c)

[

d)

()

65.

Which R operator serves to extract a single element from a list or data frame, potentially returning an object of a different class than a list or data frame?

a)

[

b)

[[

c)

$

d)

{}

66.

Which R operator is employed to retrieve elements from a list or data frame using their literal name?

a)

[

b)

[[

c)

$

d)

#

67.

When subsetting a vector with the [ operator, what can be supplied to retrieve multiple elements?

a)

Only a single integer

b)

A character string

c)

An integer sequence or an arbitrary integer vector

d)

A function name

68.

What type of sequence can be supplied to the [ operator to extract vector elements that fulfill a specific condition?

a)

Numeric sequence

b)

Character sequence

c)

Logical sequence

d)

Complex sequence

69.

When subsetting a matrix with (i,j) indices and extracting a single element (e.g., x[1, 2]), what is the default behavior concerning the dimension of the resulting object?

a)

It always returns a 1x1 matrix.

b)

It is returned as a vector of length 1.

c)

It returns an error.

d)

It returns NULL.

70.

How can one ensure R preserves matrix dimensions when extracting a single element, row, or column?

a)

By setting keep.dims = TRUE

b)

By setting drop = FALSE

c)

By using the as.matrix() function

d)

This behavior cannot be turned off.

71.

What is a key distinction between the [[ operator and the $ operator when subsetting lists?

a)

[[ can only use literal names, $ can use computed indices.

b)

[[ can be used with computed indices, $ can only be used with literal names.

c)

[[ returns a list, $ returns an atomic vector.

d)

[[ is faster than $.

72.

To access a nested element of a list (e.g., the 3rd element of the 1st element x[[c(1, 3)]]), which operator is used with an integer sequence?

a)

$

b)

[

c)

[[

d)

()

73.

When employing the [ operator to retrieve multiple elements from a list (e.g., x[c(1, 3)]), what is the class of the returned object?

a)

An atomic vector

b)

A data frame

c)

The same class as the original (a list)

d)

A matrix

74.

With which subsetting operators does R permit partial matching of names?

a)

Only [

b)

Only [[

c)

[[ and $

d)

All three [, [[, and $

75.

Which function can be employed to identify complete cases (rows without missing values) across multiple R objects, yielding a logical vector?

a)

remove.na()

b)

filter.na()

c)

complete.cases()

d)

na.omit()

76.

cts, yielding a logical vector?

a)

remove.na()

b)

filter.na()

c)

complete.cases()

d)

na.omit()

77.

How are dates internally represented in R?

a)

As character strings.

b)

As the number of seconds since 1970-01-01.

c)

As the number of days since 1970-01-01.

d)

As a list of date components.

78.

Which function is commonly used to transform a character string into a Date object?

a)

to.Date()

b)

as.date()

c)

as.Date()

d)

make.Date()

79.

What are the two primary classes R utilizes to represent times?

a)

Time and DateTime

b)

POSIXct and POSIXlt

c)

TimeDate and Time

d)

CalendarTime and EpochTime

80.

Which time class in R is characterized as "just a very large integer under the hood" and proves useful for storing times in data frames?

a)

POSIXlt

b)

POSIXct

c)

Date

d)

TimeOnly

81.

Which time class in R functions as a list and stores valuable information such as the day of the week, day of the year, month, and day of the month?

a)

POSIXct

b)

POSIXtime

c)

POSIXlt

d)

Date

82.

What function can be applied to convert dates, if they are formatted differently, into a POSIXlt object using specific formatting strings?

a)

format.time()

b)

parse.time()

c)

strptime()

d)

as.time()

83.

What mathematical operations are explicitly supported for dates and times in R?

a)

All arithmetic operations (+, -, *, /)

b)

Only + and -

c)

Only comparisons (==, <=)

d)

No mathematical operations are supported.

84.

What is a significant contribution of the dplyr package concerning data manipulation?

a)

It provides a new type of data storage.

b)

It establishes a "grammar" for data manipulation.

c)

It creates interactive dashboards.

d)

It automates machine learning models.

85.

Which dplyr function allows for selecting rows based on specified conditions?

a)

select()

b)

mutate()

c)

filter()

d)

arrange()

86.

Which dplyr function is used to choose specific columns from a data frame?

a)

filter()

b)

select()

c)

rename()

d)

summarise()

87.

Which dplyr function facilitates adding or transforming columns within a data frame?

a)

select()

b)

filter()

c)

mutate()

d)

summarise()

88.

Which dplyr function aggregates data to produce summary statistics?

a)

filter()

b)

mutate()

c)

arrange()

d)

summarise()

89.

Which dplyr function enables sorting rows based on column values?

a)

select()

b)

filter()

c)

arrange()

d)

group_by()

90.

What is the function of the pipe operator %>% in dplyr?

a)

To assign a value to a variable.

b)

To combine multiple data frames.

c)

To enable chaining of commands for more concise and readable code.

d)

To define new functions.

91.

What serves as the initial argument for functions in dplyr?

a)

A character string

b)

A numeric vector

c)

A data frame

d)

A logical condition

92.

The select() function also provides the ability to exclude variables using which symbol?

a)

+

b)

-

c)

*

d)

/

93.

The mutate() function can perform multiple transformations in a single call. Which option illustrates creating a conditional column?

a)

df <- mutate(df, total_score = score1 + score2)

b)

df <- mutate(df, score1 = score1 * 1.1)

c)

df <- mutate(df, grade = case_when(average >= 90 ~ "A", ...))

d)

df <- mutate(df, marks2 = NULL)

94.

How is a tibble primarily described in comparison to a data frame?

a)

An older, less efficient version of a data frame.

b)

A modern, tidy version of a data frame, designed for ease of use.

c)

A data structure for storing only numerical data.

d)

A specialized type of list.

95.

What is a key distinction in printing behavior between a data.frame and a tibble?

a)

data.frame prints a preview, tibble prints the entire dataset.

b)

data.frame prints the entire dataset, tibble prints a concise preview.

c)

Both print only the first 6 rows.

d)

Neither prints to the console by default.

96.

By default, how do data.frames process string columns upon import, contrasting with tibbles?

a)

data.frame converts strings to factors, tibble retains them as characters.

b)

data.frame keeps strings as characters, tibble converts them to factors.

c)

Both convert strings to factors.

d)

Both keep strings as characters.

97.

Which dplyr function is employed to modify column names in a data frame or tibble?

a)

set_names()

b)

rename_cols()

c)

rename()

d)

modify_names()

98.

When does the summarise() function exhibit its greatest utility in dplyr?

a)

When used with select().

b)

When combined with group_by() for producing grouped summaries.

c)

When applied to character vectors.

d)

When creating new columns.

99.

What is the primary function of group_by() in dplyr?

a)

To visually alter the data.

b)

To partition a dataset into groups based on one or more variables.

c)

To sort the data in ascending order.

d)

To filter rows based on a condition.

100.

Which R control structure is most commonly used for evaluating a condition and executing actions based on its truthfulness?

a)

for loop

b)

while loop

c)

if and else

d)

repeat loop

101.

What is the purpose of set.seed() in R?

a)

To generate truly random numbers.

b)

To ensure repeatability in random number generation.

c)

To reset the random number generator.

d)

To increase the range of random numbers.

102.

In an if-else if-else construction, what is the maximum number of else if clauses permitted after an initial if?

a)

Only one.

b)

Any number.

c)

Maximum of two.

d)

None, only if-else is allowed.

103.

What is the principal application of for loops in R?

a)

For testing conditions.

b)

For executing infinite loops.

c)

For iterating through the elements of an object (list, vector, etc.).

d)

For generating random numbers.

104.

What function is frequently paired with for loops to create an integer sequence corresponding to an object's length?

a)

length()

b)

seq()

c)

seq_along()

d)

count()

105.

For a for loop spanning a single line, are curly braces {} always required?

a)

Yes, always.

b)

No, they are optional.

c)

Only if there are comments.

d)

Only if variables are being assigned.

106.

How do while loops commence their execution?

a)

By executing the loop body once.

b)

By evaluating a condition.

c)

By defining a counter variable.

d)

By printing a message.

107.

Which keyword in R allows for skipping the current iteration of a loop?

a)

skip

b)

continue

c)

next

d)

pass

108.

Which keyword in R immediately terminates a loop, regardless of the ongoing iteration?

a)

exit

b)

stop

c)

break

d)

end

109.

How are functions in R characterized, permitting their treatment similar to other R objects?

a)

Second-class citizens

b)

Primitive types

c)

"First class objects"

d)

Static methods

110.

What advantage stems from functions being "first class objects" in R, particularly beneficial for "apply" functions?

a)

They can be saved to disk easily.

b)

They can be provided as arguments to other functions.

c)

They have built-in help documentation.

d)

They automatically manage missing values.

111.

What specific derivative is employed to define functions in R?

a)

define()

b)

create.function()

c)

function()

d)

func()