R Language 면접 질문과 답변
Ques 11. What is vectorization in R, and why is it important?
Vectorization is the process of applying operations to entire vectors at once. It is important for efficiency and simplicity in R programming.
Example:
vector1 <- c(1, 2, 3)
vector2 <- c(4, 5, 6)
result <- vector1 + vector2
Ques 12. Explain the concept of lazy evaluation in R.
Lazy evaluation is a feature in R where expressions are not evaluated until their values are actually needed. It can improve performance by avoiding unnecessary computations.
Example:
lazy_function <- function() { print('Lazy function') }
# The function is not executed until called: lazy_function()
Ques 13. How do you generate random numbers in R?
You can use functions like runif() for uniform distribution, rnorm() for normal distribution, and sample() for random sampling.
Example:
random_numbers <- runif(5)
Ques 14. Explain the purpose of the 'shiny' package in R.
The 'shiny' package is used to create interactive web applications directly from R. It allows users to interact with R-based visualizations through a web browser.
Example:
library(shiny)
shinyApp(ui, server)
Ques 15. What is the purpose of the 'str()' function in R?
The 'str()' function is used to display the structure of an R object. It provides a compact way to see the internal structure of data objects in R.
Example:
str(my_data)
Most helpful rated by users: