Q121
Q121 What is the class of objects created by the Sys.Date() function in R?
Date
POSIXct
POSIXlt
datetime
Q122
Q122 How can you convert a character string to a date object in R?
as.Date()
to.Date()
convert.Date()
stringToDate()
Q123
Q123 What is the primary difference between POSIXct and POSIXlt date-time classes in R?
POSIXct stores dates as strings, POSIXlt as lists
POSIXct stores dates as integers, POSIXlt as lists
POSIXct stores dates in UTC, POSIXlt in local time
There is no difference
Q124
Q124 How do you create a sequence of dates from January 1, 2021, to January 10, 2021, in R?
seq(as.Date("2021-01-01"), as.Date("2021-01-10"), by = "day")
sequence("2021-01-01", "2021-01-10")
dates("2021-01-01", "2021-01-10")
range(as.Date("2021-01-01"), as.Date("2021-01-10"))
Q125
Q125 How can you extract the month from a date object in R?
month()
extractMonth()
months()
getMonth()
Q126
Q126 If as.Date("31/12/2021") returns an NA, what is a likely cause?
Incorrect date format
Non-existent date
Year out of range
Function does not support date conversion
Q127
Q127 How can you handle time zone conversions in R?
Use the tz argument in functions like as.POSIXct()
Use the Sys.timezone() function
Use the convert.tz() function
Change system time zone settings
Q128
Q128 What is the primary difference between S3 and S4 object systems in R?
S3 is more formal than S4
S3 uses formal class definitions, S4 does not
S4 uses formal class definitions, S3 does not
There is no difference
Q129
Q129 Which function is used to define a new S3 generic function in R?
setGeneric()
UseMethod()
setMethod()
createGeneric()
Q130
Q130 What is the purpose of the setClass() function in the S4 object system in R?
To create a new S3 class
To create a new S4 class
To define a new generic function
To set a class for an object
Q131
Q131 How does method dispatch work in the S4 object system in R?
By function naming convention
By matching the method name to the class
By explicit method registration with setMethod()
By object structure analysis
Q132
Q132 How do you create an object of a new S4 class named "Person" with a slot "name" in R?
new("Person", name = "John")
create("Person", name = "John")
Person$new(name = "John")
setClass("Person", name = "John")
Q133
Q133 How can you define a method for a generic function show for an S4 class "Person" in R?
setGeneric("show", function(x) standardGeneric("show"))
setMethod("show", "Person", function(object) { ... })
show <- function(object) { ... }
generic("show", "Person", function(object) { ... })
Q134
Q134 If an S3 method is not dispatching correctly, what is a common issue to check?
Incorrect class name
Method not defined with setMethod
Method not registered
Function name mismatch
Q135
Q135 How can you inspect the structure of an S4 object to understand its slots and their values?
str(object)
slotNames(object)
getSlots(object)
show(object)
Q136
Q136 What is the primary purpose of R Markdown?
Data visualization
Web development
Reproducible reporting
Database management
Q137
Q137 Which file extension is used for R Markdown files?
.Rmd
.Rmarkdown
.md
.R
Q138
Q138 What function is used to render an R Markdown document to HTML?
render()
convert()
compile()
output()
Q139
Q139 What is a code chunk in R Markdown?
A section of code written in R language
A section of Markdown syntax
A combination of R and Markdown syntax
A section of comments only
Q140
Q140 How do you start a code chunk in an R Markdown document?
```{r}
```r
{r}
```r {```
Q141
Q141 How can you include a plot generated in R within an R Markdown document?
Create the plot in a code chunk
Save the plot as an image and embed it
Generate the plot externally
Embed the plot URL
Q142
Q142 What could be a reason for an R Markdown document failing to knit properly?
Incorrect file path
Syntax errors in code chunks
Missing package dependencies
Insufficient memory
Q143
Q143 How can you troubleshoot an error in an R Markdown document where code runs in R but not when knitted?
Check for environment differences
Check for missing library calls
Check for chunk options
Reinstall R Markdown
Q144
Q144 What is the primary goal of performance tuning in R?
To reduce code readability
To make code run faster and more efficiently
To increase the complexity of the code
To add more features to the code
Q145
Q145 Which function in R can be used to measure the execution time of a code block?
system.time()
exec.time()
time()
measure.time()
Q146
Q146 What is a common method to improve the performance of a loop in R?
Use nested loops
Use vectorized operations
Increase the loop iterations
Add more comments
Q147
Q147 How can you profile the performance of an R script to identify bottlenecks?
Use the summary() function
Use the lm() function
Use the profvis() package
Use the plot() function
Q148
Q148 Which function helps in pre-allocating memory for a vector to improve performance in R?
preallocate()
vector()
alloc()
initialize()
Q149
Q149 What could be a reason for an R script running slower than expected despite being optimized?
Hardware limitations
Incorrect code logic
Insufficient memory
All of these factors
Q150
Q150 How can parallel processing improve the performance of an R script?
By running tasks sequentially
By utilizing multiple CPU cores to run tasks simultaneously
By reducing the number of computations
By increasing the memory usage