41. Which function helps you perform sorting in R language?
42. What will be the output of the following R code?
> f <- function(num) {
+ for(i in seq_len(num)) {
+ cat("Hello, world!\n")
+ }
+ }
> f(3)
> f <- function(num) {
+ for(i in seq_len(num)) {
+ cat("Hello, world!\n")
+ }
+ }
> f(3)
43. . . . . . . . . is used to apply a function over subsets of a vector.
44. Which of the variable in the following R code is variable?
> f <- function(x, y) {
+ x^2 + y / z
+ }
> f <- function(x, y) {
+ x^2 + y / z
+ }
45. What will be the output of the following R code?
function(p) {
params[!fixed] <- p
mu <- params[1]
sigma <- params[2]
## Calculate the Normal density
a <- -0.5*length(data)*log(2*pi*sigma^2)
b <- -0.5*sum((data-mu)^2) / (sigma^2)
-(a + b)
}
> ls(environment(nLL))
function(p) {
params[!fixed] <- p
mu <- params[1]
sigma <- params[2]
## Calculate the Normal density
a <- -0.5*length(data)*log(2*pi*sigma^2)
b <- -0.5*sum((data-mu)^2) / (sigma^2)
-(a + b)
}
> ls(environment(nLL))
46. . . . . . . . . initiates an infinite loop right from the start.
47. What will be the output of runif()?
48. What will be the output of the following R code snippet?
> g <- function(x) {
+ a <- 3
+ x+a+y
+ ## 'y' is a free variable
+ }
> g(2)
> g <- function(x) {
+ a <- 3
+ x+a+y
+ ## 'y' is a free variable
+ }
> g(2)
49. . . . . . . . . will produce a sequential vector c( (1,2,3,4,5,6,7,8,9)).
50. What are the different types of sorting algorithms available in R language?
Read More Section(Control Structures in R Programming)
Each Section contains maximum 100 MCQs question on Control Structures in R Programming. To get more questions visit other sections.