Q91
Q91 Why might the sd() function return an error when applied to a dataset in R?
The dataset contains non-numeric values
The dataset is empty
Both reasons mentioned
None of the above
Q92
Q92 What function is used to read CSV files into R?
read.csv()
load.csv()
import.csv()
fetch.csv()
Q93
Q93 Which function in R is used to write data frames to a CSV file?
write.csv()
export.csv()
save.csv()
output.csv()
Q94
Q94 What is the purpose of the file() function in R?
To delete files
To create a connection to a file for reading or writing
To list files
To copy files
Q95
Q95 In R, what does the read.table() function do?
Reads data stored in a table format
Creates a table from vector data
Visualizes data in table format
None of the above
Q96
Q96 What is the main difference between read.csv() and read.csv2() in R?
The former is used for reading large files, the latter for small files
The former uses comma as delimiter, the latter uses semicolon
The former supports UTF-8 encoding, the latter does not
There is no difference
Q97
Q97 How do you save an R data frame as a tab-separated values file?
write.table(df, "data.tsv", sep="\t")
save.table(df, "data.tsv", sep="\t")
write.csv(df, "data.tsv", sep="\t")
output.tsv(df, "data.tsv", sep="\t")
Q98
Q98 Which function would you use to read a JSON file into R?
read.json()
fromJSON()
json()
load.json()
Q99
Q99 What is the correct way to read an Excel file into R using the readxl package?
read_excel("data.xlsx")
load_excel("data.xlsx")
excel_read("data.xlsx")
get_excel("data.xlsx")
Q100
Q100 How can you connect to and read from a text file that is continuously being updated, in R?
file("log.txt", "r") and then use readLines()
open("log.txt", "r") and use readText()
connect("log.txt") and use getText()
link("log.txt", "read")
Q101
Q101 If write.csv() fails to save a data frame with error in R, what might be a common cause?
Incorrect file path
File is open in another program
Both reasons
None of the above
Q102
Q102 Why might read.table() return an error when reading a file that includes different data types?
The function expects uniform data types
Incorrect delimiter used
File contains improper formatting
Both the first and second options
Q103
Q103 What is an environment in R?
A collection of data types
A collection of packages
A collection of symbol-value pairs
A collection of functions
Q104
Q104 How does R determine the value of a variable when it is used in a function?
By checking global variables only
By searching the function's environment and then parent environments
By checking the global environment first
By looking only in the base environment
Q105
Q105 Which environment is at the top of the environment hierarchy in R?
Base environment
Global environment
Empty environment
Parent environment
Q106
Q106 What does the <<- operator do in R?
Assigns a value in the current environment
Assigns a value in the global environment
Assigns a value in the parent environment
None of the above
Q107
Q107 How do you create a new environment in R and assign a variable to it?
new.env(); e$a <- 1
env(); e$a <- 1
create.env(); e$a <- 1
new.environment(); e$a <- 1
Q108
Q108 How do you list all objects in the current environment?
ls()
objects()
list()
all_objects()
Q109
Q109 How can you access the parent environment of a given environment env in R?
parent.env(env)
env$parent
parent(environment)
get.parent(env)
Q110
Q110 If a variable in a function is not found in the current environment, what is R’s next step in finding it?
R throws an error
R searches in the global environment
R searches in the parent environment
R returns NULL
Q111
Q111 How can you avoid potential scoping issues in R functions when using global variables?
Always use <<- operator
Prefix global variables with global::
Avoid using global variables
Use local variables with the same name
Q112
Q112 What is the primary purpose of the try() function in R?
To attempt execution of code that might fail without stopping the entire script
To handle errors silently
To debug code
To improve code performance
Q113
Q113 What does the traceback() function do in R?
Shows the call stack leading to the error
Provides detailed error descriptions
Fixes the error automatically
Logs the error to a file
Q114
Q114 Which function in R can be used to provide custom error messages?
stop()
error()
alert()
throw()
Q115
Q115 How do you use the tryCatch() function to handle errors in R?
tryCatch(expr, error = function(e) { ... })
tryCatch(expr, silent = TRUE)
try(expr)
catch(expr)
Q116
Q116 How can you use debug() to step through a function named my_func in R?
debug(my_func); my_func()
step(my_func)
trace(my_func)
watch(my_func)
Q117
Q117 If you encounter an "object not found" error in R, what is a likely cause?
Misspelled variable name
Incorrect function call
Package not loaded
All of the above
Q118
Q118 How can you debug an R script that runs without error but produces incorrect results?
Use print statements to inspect variables
Use a step-through debugger
Check for logical errors
All of the above
Q119
Q119 When using tryCatch(), how can you capture and analyze the error object?
error = function(e) { print(e) }
catch = function(e) { analyze(e) }
errorHandler(e) { inspect(e) }
tryError(e) { log(e) }
Q120
Q120 Which function is used to get the current date and time in R?
now()
Sys.Date()
Sys.time()
current()