WorksheetsR Language Quiz
Total questions: 111
Worksheet time: 56mins
In what year was Version 4 of the S language released, which is the version used today?
1988
1993
1998
2004
Which company serves as the current owner and exclusive developer of the S language?
Bell Labs
StatSci
Insightful Corp.
TIBCO
Among the following, identify an object class that is not considered one of the five basic or "atomic" classes in R.
numeric
string
integer
logical
Which symbol functions as the assignment operator in R?
=
<-
->
+
What is the sole character used to denote a comment in R?
//
/* */
#
--
What fundamental rule governs the composition of vectors in R?
A vector can contain objects of different classes.
A vector can only contain objects of the same class.
Vectors must always be explicitly initialized with vector().
Vectors can only store numeric data.
How does one explicitly designate an integer object in R (e.g., the number 1)?
as.integer(1)
integer(1)
1L
int(1)
What does the value NaN signify in R?
Negative infinity
Not a number
A null value
A zero value
Which R object type is described as a "special type of vector that can contain elements of different classes"?
Matrix
Data Frame
Factor
List
When importing larger datasets using read.table(), what benefit arises from employing the colClasses argument?
It ensures R reads the entire file by default.
It prevents R from incorrectly guessing column types.
It automatically sets the comment character.
It speeds up the data writing process.
What was the initial implementation of the S language at Bell Telephone Laboratories?
C++ libraries
Python scripts
Fortran libraries
Java applications
In what year was the S system re-engineered in C, marking its progression to Version 3 and its current form?
1993
1988
1998
2006
Which book, famously known as "the white book," documents the statistical analysis capabilities of S?
Programming with Data
The Art of R Programming
Statistical Models in S
Advanced R
The book "Programming with Data" by John Chambers, recognized as "the green book," provides documentation for which version of the S language?
Version 2
Version 3
Version 4
Version 5
How much did Insightful pay Lucent in 2004 to acquire the S language?
$1 million
$2 million
$2.5 million
$25 million
Which highly esteemed award did S receive in 1998 within the computer science domain?
Turing Award
Nobel Prize in Computer Science
Association for Computing Machinery's Software System Award
IEEE John von Neumann Medal
A defining characteristic of R in its early stages was its syntactic resemblance to which language, facilitating a smooth transition for S-PLUS users?
Python
Java
S
C++
Although R's syntax mirrors S's, its underlying semantics are fundamentally closer to which language?
Fortran
Scheme
C
Pascal
What fundamental philosophical aspect of S has R preserved, focusing on its utility for both interactive tasks and the creation of new tools?
Closed-source development
Proprietary licensing
Open-source only tools
A language useful for interactive work and powerful for programming new tools
What is a significant advantage of using R, independent of the language itself?
Its high performance for large datasets
Its pre-built graphical user interfaces
Its active and vibrant user community
Its strict adherence to academic standards
What is the primary source for the R system, also recognized as CRAN?
R-Forge
GitHub
Comprehensive R Archive Network
Bioconductor
What foundational component resides in the "base" R system, essential for R's operation and containing its core functions?
Only recommended packages
The base package
User-contributed packages
All CRAN packages
How many user-developed packages are approximately accessible on CRAN?
Hundreds
Over 4000
Tens of thousands
Fewer than 100
What specific symbol is designated as the assignment operator in R?
=
==
<-
->
What does the character # signify within R code?
A string literal
A code block
A comment
An operator for exponentiation
Does R offer support for multi-line comments or comment blocks?
Yes, using /* */
Yes, using ``
R only supports single-line comments with #.
Yes, using ///
When an expression is input at the R prompt, what action follows its evaluation?
It is saved to a file.
The R session is terminated.
The result of the evaluated expression is returned.
It is automatically converted to a function.
What does [1] signify in the R output [1] 5?
The value 1 is part of the vector.
The output is from the first line of code.
That x is a vector and 5 is its first element.
It's an error message.
By default, how does R generally categorize numbers?
Integer objects
Character objects
Numeric objects (double precision real numbers)
Complex objects
To explicitly establish an integer object in R, which suffix should be appended to the number?
D
L
I
F
What specific number in R denotes infinity, facilitating calculations like 1 / 0?
NULL
NA
Inf
Undefined
Which operator facilitates the creation of integer sequences in R (e.g., 110)?
-
+
*
What best describes the "attributes" of an R object?
The data stored within the object
The functions that operate on the object
Metadata for the object
The object's memory address
Which function provides access to the attributes of an R object?
get_attributes()
attr()
attributes()
list.attributes()
What function is commonly utilized to construct vectors by combining elements?
concatenate()
combine()
c()
vector()
When diverse object classes are combined within a vector (e.g., c(1.7, "a")), what process ensures all elements share the same class?
Error generation
Automatic deletion of incompatible elements
Coercion
Conversion to a list
What results from combining a numeric object with a character object in a vector (e.g., c(1, "a"))?
A numeric vector with NA for the character.
An error.
A character vector.
A logical vector.
How can objects be explicitly transformed from one class to another in R, if such a conversion is supported?
Using convert_to() functions
Using change_class() functions
Using as.* functions (e.g., as.numeric())
Using the coerce() function
What is the fundamental nature of matrices in R, with an additional characteristic?
Lists with numeric elements
Factors with dimensions
Vectors with a dimension attribute
Data frames with a single column
How are matrices constructed by default in R?
Row-wise
Column-wise
Diagonally
Randomly
Which functions facilitate the creation of matrices by binding columns or rows?
bind_cols() and bind_rows()
col_bind() and row_bind()
cbind() and rbind()
merge_cols() and merge_rows()
What is a defining feature of lists concerning the variety of elements they can encompass?
They can only contain numeric elements.
They must contain elements of the same class.
They can contain elements of different classes.
They can only contain other lists.
How can factors be conceptualized in R?
As character vectors with numeric labels
As integer vectors where each integer has a label
As logical vectors with categorical names
As complex numbers with predefined levels
What advantage do factors with labels (e.g., "Male", "Female") offer over using integers (e.g., 1, 2) for categorical data?
Factors are more memory efficient.
Factors are self-describing.
Factors can store more categories.
Factors are faster for computations.
Which function is utilized to generate factor objects?
as.factor()
make.factor()
factor()
create_factor()
What argument within the factor() function allows for setting the specific order of a factor's levels?
order
levels
labels
sequence
How does R denote missing values resulting from undefined mathematical operations?
NULL
Error
NA or NaN
Missing
Which function serves to verify if objects are NA?
is.null()
is.na()
test.na()
check.na()
Which function specifically identifies NaN values?
is.na()
is.nan()
has.nan()
test.nan()
Is a NaN value considered NA?
They are entirely distinct.
Yes, but the reverse is not true.
Only if it's a numeric NA.
Only when explicitly coerced.
What is a particularly valuable reason for assigning names to R objects?
To make them faster to process.
For writing readable code and self-describing objects.
To reduce their memory footprint.
To enable automatic type conversion.
According to the document, what is the distinction in usage between names() and row.names() for data frames?
names() is for row names, row.names() is for column names.
names() is for column names, row.names() is for row names.
Both names() and row.names() are for column names.
Data frames only have row.names().
How are data frames internally structured in R?
As a special type of matrix.
As a specialized type of vector.
As a special type of list where every element has the same length.
As a collection of atomic classes.
What is a key difference between data frames and matrices concerning the classes of objects they can store?
Matrices can store different classes, data frames cannot.
Data frames can store different classes in each column, while matrices require all elements to be of the same class.
Both data frames and matrices can store different classes.
Neither can store different classes.
What function is typically employed to create data frames by importing a dataset?
create.dataframe()
load.data()
read.table() or read.csv()
dataframe()
What is the specific function of readLines?
For reading tabular data.
For reading individual lines from a text file.
For reading in R code files.
For reading saved workspaces.
What is the purpose of the dget function?
For writing tabular data.
For reading R objects from a file (the inverse of dput).
For saving R objects in binary format.
For converting an R object to binary.
What is the function of write.table?
For writing character data line-by-line.
For dumping a textual representation of multiple R objects.
For saving arbitrary R objects in binary format.
For writing tabular data to text files (e.g., CSV).
What is the default comment.char setting in read.table()?
*
//
#
--
If your file contains no commented lines, what value is advisable to set for comment.char in read.table()?
NULL
NA
The empty string ""
.
What is a significant advantage of utilizing the colClasses argument in functions like read.table() for large files?
It increases the number of rows read.
It notably accelerates the data reading process.
It automatically handles missing values.
It converts all strings to factors.
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?
144 MB
1.34 GB
14.4 GB
134 MB
What common undesirable situation can arise when attempting to import a large dataset into R without sufficient RAM?
R automatically compresses the data.
R spills data to disk, slowing down.
Your computer (or at least your R session) may freeze.
R automatically scales down the dataset.
Which R operator consistently yields an object of the same class as the original during subsetting?
[[
$
[
()
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?
[
[[
$
{}
Which R operator is employed to retrieve elements from a list or data frame using their literal name?
[
[[
$
#
When subsetting a vector with the [ operator, what can be supplied to retrieve multiple elements?
Only a single integer
A character string
An integer sequence or an arbitrary integer vector
A function name
What type of sequence can be supplied to the [ operator to extract vector elements that fulfill a specific condition?
Numeric sequence
Character sequence
Logical sequence
Complex sequence
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?
It always returns a 1x1 matrix.
It is returned as a vector of length 1.
It returns an error.
It returns NULL.
How can one ensure R preserves matrix dimensions when extracting a single element, row, or column?
By setting keep.dims = TRUE
By setting drop = FALSE
By using the as.matrix() function
This behavior cannot be turned off.
What is a key distinction between the [[ operator and the $ operator when subsetting lists?
[[ can only use literal names, $ can use computed indices.
[[ can be used with computed indices, $ can only be used with literal names.
[[ returns a list, $ returns an atomic vector.
[[ is faster than $.
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?
$
[
[[
()
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?
An atomic vector
A data frame
The same class as the original (a list)
A matrix
With which subsetting operators does R permit partial matching of names?
Only [
Only [[
[[ and $
All three [, [[, and $
Which function can be employed to identify complete cases (rows without missing values) across multiple R objects, yielding a logical vector?
remove.na()
filter.na()
complete.cases()
na.omit()
cts, yielding a logical vector?
remove.na()
filter.na()
complete.cases()
na.omit()
How are dates internally represented in R?
As character strings.
As the number of seconds since 1970-01-01.
As the number of days since 1970-01-01.
As a list of date components.
Which function is commonly used to transform a character string into a Date object?
to.Date()
as.date()
as.Date()
make.Date()
What are the two primary classes R utilizes to represent times?
Time and DateTime
POSIXct and POSIXlt
TimeDate and Time
CalendarTime and EpochTime
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?
POSIXlt
POSIXct
Date
TimeOnly
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?
POSIXct
POSIXtime
POSIXlt
Date
What function can be applied to convert dates, if they are formatted differently, into a POSIXlt object using specific formatting strings?
format.time()
parse.time()
strptime()
as.time()
What mathematical operations are explicitly supported for dates and times in R?
All arithmetic operations (+, -, *, /)
Only + and -
Only comparisons (==, <=)
No mathematical operations are supported.
What is a significant contribution of the dplyr package concerning data manipulation?
It provides a new type of data storage.
It establishes a "grammar" for data manipulation.
It creates interactive dashboards.
It automates machine learning models.
Which dplyr function allows for selecting rows based on specified conditions?
select()
mutate()
filter()
arrange()
Which dplyr function is used to choose specific columns from a data frame?
filter()
select()
rename()
summarise()
Which dplyr function facilitates adding or transforming columns within a data frame?
select()
filter()
mutate()
summarise()
Which dplyr function aggregates data to produce summary statistics?
filter()
mutate()
arrange()
summarise()
Which dplyr function enables sorting rows based on column values?
select()
filter()
arrange()
group_by()
What is the function of the pipe operator %>% in dplyr?
To assign a value to a variable.
To combine multiple data frames.
To enable chaining of commands for more concise and readable code.
To define new functions.
What serves as the initial argument for functions in dplyr?
A character string
A numeric vector
A data frame
A logical condition
The select() function also provides the ability to exclude variables using which symbol?
+
-
*
/
The mutate() function can perform multiple transformations in a single call. Which option illustrates creating a conditional column?
df <- mutate(df, total_score = score1 + score2)
df <- mutate(df, score1 = score1 * 1.1)
df <- mutate(df, grade = case_when(average >= 90 ~ "A", ...))
df <- mutate(df, marks2 = NULL)
How is a tibble primarily described in comparison to a data frame?
An older, less efficient version of a data frame.
A modern, tidy version of a data frame, designed for ease of use.
A data structure for storing only numerical data.
A specialized type of list.
What is a key distinction in printing behavior between a data.frame and a tibble?
data.frame prints a preview, tibble prints the entire dataset.
data.frame prints the entire dataset, tibble prints a concise preview.
Both print only the first 6 rows.
Neither prints to the console by default.
By default, how do data.frames process string columns upon import, contrasting with tibbles?
data.frame converts strings to factors, tibble retains them as characters.
data.frame keeps strings as characters, tibble converts them to factors.
Both convert strings to factors.
Both keep strings as characters.
Which dplyr function is employed to modify column names in a data frame or tibble?
set_names()
rename_cols()
rename()
modify_names()
When does the summarise() function exhibit its greatest utility in dplyr?
When used with select().
When combined with group_by() for producing grouped summaries.
When applied to character vectors.
When creating new columns.
What is the primary function of group_by() in dplyr?
To visually alter the data.
To partition a dataset into groups based on one or more variables.
To sort the data in ascending order.
To filter rows based on a condition.
Which R control structure is most commonly used for evaluating a condition and executing actions based on its truthfulness?
for loop
while loop
if and else
repeat loop
What is the purpose of set.seed() in R?
To generate truly random numbers.
To ensure repeatability in random number generation.
To reset the random number generator.
To increase the range of random numbers.
In an if-else if-else construction, what is the maximum number of else if clauses permitted after an initial if?
Only one.
Any number.
Maximum of two.
None, only if-else is allowed.
What is the principal application of for loops in R?
For testing conditions.
For executing infinite loops.
For iterating through the elements of an object (list, vector, etc.).
For generating random numbers.
What function is frequently paired with for loops to create an integer sequence corresponding to an object's length?
length()
seq()
seq_along()
count()
For a for loop spanning a single line, are curly braces {} always required?
Yes, always.
No, they are optional.
Only if there are comments.
Only if variables are being assigned.
How do while loops commence their execution?
By executing the loop body once.
By evaluating a condition.
By defining a counter variable.
By printing a message.
Which keyword in R allows for skipping the current iteration of a loop?
skip
continue
next
pass
Which keyword in R immediately terminates a loop, regardless of the ongoing iteration?
exit
stop
break
end
How are functions in R characterized, permitting their treatment similar to other R objects?
Second-class citizens
Primitive types
"First class objects"
Static methods
What advantage stems from functions being "first class objects" in R, particularly beneficial for "apply" functions?
They can be saved to disk easily.
They can be provided as arguments to other functions.
They have built-in help documentation.
They automatically manage missing values.
What specific derivative is employed to define functions in R?
define()
create.function()
function()
func()
