Q. Explain what is R?
Ans : R is data analysis software which is used by analysts, quants, statisticians, data scientists and others.
Q. List out some of the function that R provides?
Ans : The function that R provides are
Mean
Median
Distribution
Covariance
Regression
Non-linear
Mixed Effects
GLM
GAM. etc.
Q. Explain how you can start the R commander GUI?
Ans : Typing the command, ("Rcmdr") into the R console starts the R commander GUI.
Q. In R how you can import Data?
Ans : You use R commander to import Data in R, and there are three ways through which you can enter data into it
You can enter data directly via Data New Data Set
Import data from a plain text (ASCII) or other files (SPSS, Minitab, etc.)
Read a data set either by typing the name of the data set or selecting the data set in the dialog box
Q. Mention what does not ‘R’ language do?
Ans : Though R programming can easily connects to DBMS is not a database
R does not consist of any graphical user interface
Though it connects to Excel/Microsoft Office easily, R language does not provide any spreadsheet view of data
Q. Explain how R commands are written?
Ans : In R, anywhere in the program you have to preface the line of code with a #sign, for example
# subtraction
# division
# note order of operations exists
Q. How can you save your data in R?
Ans : To save data in R, there are many ways, but the easiest way of doing this is
Go to Data > Active Data Set > Export Active Data Set and a dialogue box will appear, when you click ok the dialogue box let you save your data in the usual way.
Q. Mention how you can produce co-relations and covariances?
Ans : You can produce co-relations by the cor () function to produce co-relations and cov () function to produce covariances.
Q. What are the disadvantages of R?
Ans : Just as you should know what R does well, you should understand its failings.
Memory and performance. In comparison to Python, R is often said to be the lesser language in terms of memory and performance. This is disputable, and many think it’s no longer relevant as 64-bit systems dominate the marketplace.
Q. What are the different data types/objects in R?
Ans : This is another good opportunity to show that you know R, and you’re not winging it. Unlike other object-oriented languages such as C, R doesn’t ask users to declare a data type when assigning a variable. Instead, everything in R correlates to an R data object. When you assign a variable in R, you assign it a data object and that object’s data type determines the data type of the variable. The most commonly used data objects include:
Vectors
Matrices
Lists
Arrays
Factors
Data frames
Q. What are the objects you use most frequently?
Ans : This question is meant to gather a sense of your experiences in R. Simply think about some recent work you’ve done in R and explain the data objects you use most often. If you use arrays frequently, explain why and how you’ve used them.
Q. Why use R?
Ans : This is a variant of the “advantages of R” question. Reasons to use R include its open-source nature and the fact that it’s a versatile tool for statistical plotting, analysis, and portrayal. Don’t be afraid to give some personal reasons as well. Maybe you simply love the assignment operator in R or feel that it’s more elegant than other languages—but always remember to explicate. You should be answering follow-up questions before they’re even asked.
Q. What are some of your favorite functions in R?
Ans : a user of R, you should be able to come up with some functions on the spot and describe them. Functions that save time and, as a result, money will always be something an interviewer likes to hear about.
Q. Write a custom function in R
Ans : Sometimes you’ll be asked to create a custom function on the fly. An example of a custom function from quick-r’s guide:
myFunction <- function(arg1, arg2, ... ){
statements
return(object)
}
Functions can be simple or complex, but they should make your code more extensible, readable, and efficient. This is a chance to show your ingenuity and experience.
Q. How do you concatenate strings in R?
Ans : Concatenating strings in R is less than intuitive. You don’t use a . operator, nor a + operator, and forget about the & operator. In fact, you don’t use an operator at all. Concatenating strings in R requires the use of the paste() function. Here’s an example:
hello <- "Hello, "
world <- "World."
paste(hello, world)
[1] "Hello, World."
I’ve stored Hello, and World. in variables aptly named hello and world. With paste(), I’ve simply plugged in the two variables, and it concatenates them such that it creates the single phrase “Hello, World.”
An oddity with this function is that it will automatically insert spaces between the terms. Try it out with some numbers.
paste(1,2,3,4)
[1] "1 2 3 4
This can be a sort of “gotcha” with this question. If we don’t want spaces, we can adjust the sep parameter in the function, which defaults to a space " ".
paste(1,2,3,4,sep=“”)
[1] "1234"
Q. How do you read a CSV file in R?
Ans : We’ve covered this already with the import process. Simply use the read.csv() function.
yourRDateHere <- read.csv("Data.csv", header = TRUE)
Q. What are 3 sorting algorithms available in R?
R uses the sort() function to order a vector or factor, listed and described below.
Radix: Usually the most performant algorithm, this is a non-comparative sorting algorithm that avoids overhead. It’s stable, and it’s the default algorithm for integer vectors and factors.
Quick Sort: This method “uses Singleton (1969)’s implementation of Hoare’s Quicksort method and is only available when x is numeric (double or integer) and partial is NULL,” according to R Documentation. It’s not considered a stable sort.
Shell: This method “uses Shellsort (an O(n4/3) variant from Sedgewick (1986)),” according to R Documentation.
0 Comments