## How R commands are written?

By using # at the starting of the line of code like #division commands are written.

## What is t-tests() in R?

It is used to determine that the means of two groups are equal or not by using t.test() function.

## What are the disadvantages of R Programming?

The disadvantages are:-

- Lack of standard GUI
- Not good for big data.
- Does not provide spreadsheet view of data.

<**click for R programming**>

## What is the use of With () and By () function in R?

with() function applies an expression to a dataset.

#with(data,expression)

By() function applies a function t each level of a factors.

#by(data,factorlist,function)

## In R programming, how missing values are represented?

In R missing values are represented by NA which should be in capital letters.

## What is the use of subset() and sample() function in R?

Subset() is used to select the variables and observations and sample() function is used to generate a random sample of the size n from a dataset.

## Explain what is transpose?

Transpose is used for reshaping of the data which is used for analysis. Transpose is performed by t() function.

## What are the advantages of R?

- The advantages are:-
- It is used for managing and manipulating of data.
- No license restrictions
- Free and open source software.
- Graphical capabilities of R are good.
- Runs on many Operating system and different hardware and also run on 32 & 64 bit processors etc.

Now that you are aware of the benefits of R programming

## What is the function used for adding datasets in R?

For adding two datasets rbind() function is used but the column of two datasets must be same.

Syntax: rbind(x1,x2……) where x1,x2: vector, matrix, data frames.

## How you can produce co-relations and covariances?

Cor-relations is produced by cor() and covariances is produced by cov() function.

## What is difference between matrix and dataframes?

Dataframe can contain different type of data but matrix can contain only similar type of data.

## What is difference between matrix and dataframes?

lapply is used to show the output in the form of list whereas sapply is used to show the output in the form of vector or data frame.

## What is the difference between seq(4) and seq_along(4)?

Seq(4) means vector from 1 to 4 (c(1,2,3,4)) whereas seq_along(4) means a vector of the length(4) or 1(c(1)).

## Explain how you can start the R commander GUI?

rcmdr command is used to start the R commander GUI.

## What is the memory limit of R?

In 32 bit system memory limit is 3Gb but most versions limited to 2Gb and in 64 bit system memory limit is 8Tb.

## How many data structures R has?

There are 5 data structure in R i.e. vector, matrix, array which are of homogenous type and other two are list and data frame which are heterogeneous.

## Explain how data is aggregated in R?

There are two methods that is collapsing data by using one or more BY variable and other is aggregate() function in which BY variable should be in list.

## Explain how you can start the R commander GUI?

Typing the command, (“Rcmdr”) into the R console starts the R commander GUI.

## What are R packages?

Packages are the collections of data, R functions and compiled code in a well-defined format and these packages are stored in library.

## What is the workspace in R?

Workspace is the current R working environment which includes any user defined objects like vector, lists etc.

## What is the function which is used for merging of data frames horizontally in R?

Merge()function is used to merge two data frames

Eg. Sum<-merge(data frame1,data frame 2,by=’ID’.

## what is the function which is used for merging of data frames vertically in R?

rbind() function is used to merge two data frames vertically.

Eg.

Sum<- rbind(data frame1,data frame 2)

## What is the power analysis?

It is used for experimental design .It is used to determine the effect of given sample size.

## Which package is used for power analysis in R?

Pwr package is used for power analysis in R.

## Which method is used for exporting the data in R?

There are many ways to export the data into another formats like SPSS, SAS , Stata , Excel Spreadsheet.

## Which packages are used for exporting of data?

For excel xlsReadWrite package is used and for sas,spss ,stata foreign package is implemented.

## How impossible values are represented in R?

In R NaN is used to represent impossible values.

## Which command is used for storing R object into a file?

Save command is used for storing R objects into a file.

Syntax: >save(z,file=”z.Rdata”)

## Which command is used for restoring R object from a file?

load command is used for storing R objects from a file.

Syntax: >load(”z.Rdata”)

## What is the use of coin package in R?

Coin package is used to achieve the re randomization or permutation based statistical tests.

## Which function is used for sorting in R?

order() function is used to perform the sorting.

## What is the use of tapply?

IOS-6.1.3

## What happens when the application object does not handle an event?

The event will be dispatched to your delegate for processing.

## Explain app specific objects which store the app contents?

The app specific objects are Data model objects that store app’s contents.

## Explain the purpose of using UIWindow object?

UIWindow object coordinates the one or more views presenting on the screen.

## Tell me the super class of all view controller objects?

UIView Controller class.

## How to create axes in the graph?

Using axes() function custom axes are created.

## What is the use of abline() function?

abline() function is add the reference line to a graph.

Syntax:-

abline(h=yvalues, v=xvalues)

## Why vcd package is used?

vcd package provides different methods for visualizing multivariate categorical data.

## What is GGobi?

GGobi is an open source program for visualization for exploring high dimensional typed data.

## What is iPlots?

It is a package which provide bar plots, mosaic plots, box plots, parallel plots, scatter plots and histograms

## What is the use of lattice package?

lattice package is to improve on base R graphics by giving better defaults and it have the ability to easily display multivariate relationships.

## What is fitdistr() function?

It is used to provide the maximum likelihood fitting of univariate distributions. It is defined under the MASS package.

## Which data structures are used to perform statistical analysis and create graphs?

Data structures are vectors, arrays, data frames and matrices.

## What is the use of sink() function?

It defines the direction of output.

## Why library() function is used?

This function is used to show the packages which are installed.

## Why search() function is used?

By this function we see that which packages are currently loaded.

## On which type of data binary operators are worked?

Binary operators are worked on matrices, vectors and scalars.

## What is the use of doBY package?

It is used to define the desired table using function and model formula.

## Explain how you can start the R commander GUI?

Typing the command, (“Rcmdr”) into the R console starts the R commander GUI.

## What is R Programming?

R is a programming language meant for statistical analysis and creating graphs for this purpose.Instead of data types, it has data objects which are used for calculations. It is used in the fields of data mining, Regression analysis, Probability estimation etc., using many packages available in it.

## What are the different data objects in R?

There are 6 data objects in R. They are vectors, lists, arrays, matrices, data frames and tables.

## What makes a valid variable name in R?

A valid variable name consists of letters, numbers and the dot or underline characters. The variable name starts with a letter or the dot not followed by a number.

## What is the main difference between an Array and a matrix?

A matrix is always two dimensional as it has only rows and columns. But an array can be of any number of dimensions and each dimension is a matrix. For example a 3x3x2 array represents 2 matrices each of dimension 3×3.

## Which data object in R is used to store and process categorical data?

The Factor data objects in R are used to store and process categorical data in R.

## How can you load and use csv file in R?

A csv file can be loaded using the read.csv function. R creates a data frame on reading the csv files using this function.

## How do you get the name of the current working directory in R?

The command getwd() gives the current working directory in the R environment.

## 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.

## How R is used in logistic regression?

Logistic regression deals with measuring the probability of a binary response variable. In R the function glm() is used to create the logistic regression.

## How do you access the element in the 2nd column and 4th row of a matrix named M?

The expression M[4,2] gives the element at 4th row and 2nd column.

## What is recycling of elements in a vector? Give an example?

When two vectors of different length are involved in a operation then the elements of the shorter vector are reused to complete the operation. This is called element recycling. Example – v1 <- c(4,1,0,6) and V2 <- c(2,4) then v1*v2 gives (8,4,0,24). The elements 2 and 4 are repeated.

## What are different ways to call a function in R?

We can call a function in R in 3 ways. First method is to call by using position of the arguments. Second method id to call by using the name of the arguments and the third method is to call by default arguments.

## What is lazy function evaluation in R?

The lazy evaluation of a function means, the argument is evaluated only if it is used inside the body of the function. If there is no reference to the argument in the body of the function then it is simply ignored.

## How do you install a package in R?

To install a package in R we use the below command.

install.packages("package Name")

## Name a R packages which is used to read XML files?

The package named “XML” is used to read and process the XML files.

## Can we update and delete any of the elements in a list?

We can update any of the element but we can delete only the element at the end of the list.

## Give the general expression to create a matrix in R?

The general expression to create a matrix in R is – matrix(data, nrow, ncol, byrow, dimnames)

## which function is used to create a boxplot graph in R?

The boxplot() function is used to create boxplots in R. It takes a formula and a data frame as inputs to create the boxplots.

## In doing time series analysis, what does frequency = 6 means in the ts() function?

Frequency 6 indicates the time interval for the time series data is every 10 minutes of an hour.

## What is 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.

## What is the output of runif(4)?

It generates 4 random numbers between 0 and 1.

## How to get a list of all the packages installed in R ?

Use the command

installed.packages()

## 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.

## Give a R script to extract all the unique words in uppercase from the string - ``The quick brown fox jumps over the lazy dog?

x <- "The quick brown fox jumps over the lazy dog" split.string <- strsplit(x, " ") extract.words <- split.string[[1]] result <- unique(tolower(extract.words)) print(result)

## Vector v is c(1,2,3,4) and list x is list(5:8), what is the output of v*x`{`1`}`?

Error in v * x[1] : non-numeric argument to binary operator.

#### Vector v is c(1,2,3,4) and list x is list(5:8), what is the output of v*x`{``{`1`}``}`?

[1] 5 12 21 32s

## What does unlist() do?

It converts a list to a vector.

## Give the R expression to get 26 or less heads from a 51 tosses of a coin using pbinom?

x <- pbinom(26,51,0.5) print(x)

## X is the vector c(5,9.2,3,8.51,NA), What is the output of mean(x)?

NA

## How do you convert the data in a JSON file to a data frame?

Using the function as.data.frame()

## Give a function in R that replaces all missing values of a vector x with the sum of elements of that vector?

function(x) { x[is.na(x)] <- sum(x, na.rm = TRUE); x }

## 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.

## Is an array a matrix or a matrix an array?

Every matrix can be called an array but not the reverse. Matrix is always two dimensional but array can be of any dimension.

## How to find the help page on missing values?

?NA

## How do you get the standard deviation for a vector x?

sd(x, na.rm=TRUE)

## How do you set the path for current working directory in R?

setwd(“Path”)

## What is the difference between ``%%`` and ``%/%``?

“%%” gives remainder of the division of first vector with second while “%/%” gives the quotient of the division of first vector with second.

## What does col.max(x) do?

Find the column has the maximum value for each row.

## Give the command to create a histogram?

hist()

## How do you remove a vector from the R workspace?

rm(x)

## List the data sets available in package ``MASS``?

data(package = “MASS”)

## List the data sets available in all available packages?

data(package = .packages(all.available = TRUE))

## What is the use of the command - install.packages(file.choose(), repos=NULL)?

It is used to install a r package from local directory by browsing and selecting the file.

## Give the command to check if the element 15 is present in vector x?

15 %in% x

## Give the syntax for creating scatterplot matrices?

pairs(formula, data)

Where formula represents the series of variables used in pairs and data represents the data set from which the variables will be taken.

## What is the difference between subset() function and sample() function in R?

The subset() functions is used to select variables and observations. The sample() function is used to choose a random sample of size n from a dataset.

## How do you check if ``m`` is a matrix data object in R?

is.matrix(m) should retrun TRUE.

## What is the output for the below expression all(NA==NA)?

[1] NA

## How to obtain the transpose of a matrix in R?

The function t() is used for transposing a matrix. Example – t(m) , where m is a matrix.

## 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.