R Language вопросы и ответы для интервью
Вопрос 26. Explain the concept of closures in R.
Closures in R allow functions to capture and store the environment in which they were created. This is useful for creating functions with embedded data or behavior.
Example:
closure_function <- function() {
x <- 10
function() { x + 1 }
}
Вопрос 27. How can you read data from a CSV file in R?
You can use the 'read.csv()' function to read data from a CSV file in R.
Example:
my_data <- read.csv('file.csv')
Вопрос 28. What is the purpose of the 'setwd()' function in R?
The 'setwd()' function is used to set the working directory in R. It changes the current working directory to the specified path.
Example:
setwd('/path/to/directory')
Вопрос 29. How can you install and load a package in R using a single command?
You can use the 'install.packages()' and 'library()' functions in a single line to install and load a package.
Example:
install.packages('my_package'); library('my_package')
Вопрос 30. Explain the purpose of the 'summary()' function in R.
The 'summary()' function is used to obtain a summary of the central tendency, dispersion, and shape of a distribution.
Example:
summary(my_data)
Самое полезное по оценкам пользователей: