What do you understand by a workspace in R programming language?
Answer:
The current R working environment of a user that has user defined objects like lists, vectors, etc. is referred to as Workspace in R language.
ViewWhat are the rules to define a variable name in R programming language?
Answer:
A variable name in R programming language can contain numeric and alphabets along with special characters like dot (.) and underline (-). Variable names in R language can begin with an alphabet or the dot symbol. However, if the variable name begins with a dot symbol it should not be a followed by a numeric digit.
ViewWhat is the difference between library() and require() functions in R language?
Answer:
There is no real difference between the two if the packages are not being loaded inside the function. require () function is usually used inside 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.
ViewHow will you check if an element 25 is present in a vector?
Answer:
There are various ways to do this-
How will you create scatterplot matrices in R language?
Answer:
A matrix of scatterplots can be produced using pairs. Pairs function takes various parameters like formula, data, subset, labels, etc.
The two key parameters required to build a scatterplot matrix are –
What is the purpose of using Next statement in R language?
Answer:
If a developer wants to skip the current iteration of a loop in the code without terminating it then they can use the next statement. Whenever the R parser comes across the next statement in the code, it skips evaluation of the loop further and jumps to the next iteration of the loop.
ViewHow can you resample statistical tests in R language?
Answer:
Coin package in R provides various options for re-randomization and permutations based on statistical tests. When test assumptions cannot be met then this package serves as the best alternative to classical methods as it does not assume random sampling from well-defined populations.
ViewThere is a function fn(a, b, c, d, e) a + b * c - d / e. Write the code to call fn on the vector c(1,2,3,4,5) such that the output is same as fn(1,2,3,4,5).
Answer:
do.call (fn, as.list(c (1, 2, 3, 4, 5)))
ViewWhat is the use of sample and subset functions in R programming language?
Answer:
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.
ViewHow will you measure the probability of a binary response variable in R language?
Answer:
Logistic regression can be used for this and the function glm () in R language provides this functionality.
ViewHow can you verify if a given object “X” is a matrix data object?
Answer:
If the function call is.matrix(X) returns true then X can be considered as a matrix data object otheriwse not.
ViewWhat do you understand by element recycling in R?
Answer:
If two vectors with different lengths perform an operation –the elements of the shorter vector will be re-used to complete the operation. This is referred to as element recycling.
Example – Vector A <-c(1,2,0,4) and Vector B<-(3,6) then the result of A*B will be ( 3,12,0,24). Here 3 and 6 of vector B are repeated when computing the result.
ViewHow can you verify if a given object “X” is a matric data object?
Answer:
If the function call is.matrix(X ) returns TRUE then X can be termed as a matrix data object.
ViewHow do you write R commands?
Answer:
The line of code in R language should begin with a hash symbol (#).
ViewHow will you read a .csv file in R language?
Answer:
read.csv () function is used to read a .csv file in R language. Below is a simple example –
filcontent <-read.csv (sample.csv)
print (filecontent)
ViewDifferentiate between seq (6) and seq_along (6)
Answer:
Seq_along(6) will produce a vector with length 6 whereas seq(6) will produce a sequential vector from 1 to 6 c( (1,2,3,4,5,6)).
ViewDifferentiate between lapply and sapply.
Answer:
If the programmers want the output to be a data frame or a vector, then sapply function is used whereas if a programmer wants the output to be a list then lapply is used. There one more function known as vapply which is preferred over sapply as vapply allows the programmer to specific the output type. The disadvantage of using vapply is that it is difficult to be implemented and more verbose.
ViewWhat happens if the application object is not able to handle an event?
Answer:
The event is dispatched to the delegate for processing.
ViewWrite a function in R language to replace the missing value in a vector with the mean of that vector.
Answer:
mean impute <- function(x) {x [is.na(x)] <- mean(x, na.rm = TRUE); x}
ViewHow can you debug and test R programming code?
Answer:
R code can be tested using Hadley’s testthat package.
View© 2017 QuizBucket.org