31. What is R Base package?
This is the package which is loaded by default when R environment is set. It provides the basic functionalities like input/output, arithmetic calculations etc. in the R environment.
32. What is the reshaping of data in R?
In R the data objects can be converted from one form to another. For example, we can create a data frame by merging many lists. This involves a series of R commands to bring the data into the new format. This is called data reshaping.
33. What is the use of “next” statement in R?
The “next” statement in R programming language is useful when we want to skip the current iteration of a loop without terminating it.
34. Write a function in R language to replace the missing value in a vector with the mean of that vector.
mean impute <- function(x) {x [is.na(x)] <- mean(x, na.rm = TRUE); x}
35. How can you verify if a given object āXā is a matrix data object?
If the function call is.matrix(X) returns true then X can be considered as a matrix data object otherwise not.
36. What is the use of sample and subset functions in R programming language?
- Sample () function can be used to select a random sample of size ānā from a huge dataset.
- Subset () function is used to select variables and observations from a given dataset.
37. What is the use of apply() in R?
It is used to apply the same function to each of the elements in an Array. For example, finding the mean of the rows in every row.
38. What is expected from running the command – strsplit(x,”e”)?
It splits the strings in vector x into substrings at the position of letter e.
39. What is the difference between the library() and require() functions in R language?
There is no real difference between the two if the packages are not being loaded inside the function. require () function is usually used inside the function and throws a warning whenever a particular package is not found. On the flip side, library () function gives an error message if the desired package cannot be loaded.
40. How will you list all the datasets available in all R packages?
Using the below line of code –
data(package = .packages(all.available = TRUE))