81. Mention how you can produce co-relations and covariances?
You can produce co-relations by the cor () function to produce co-relations and cov () function to produce covariances.
82. How can you save your data in R?
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 DataSet and a dialogue box will appear, when you click ok the dialogue box let you save your data in the usual way.
83. In R how missing values are represented?
In R missing values are represented by NA (Not Available), why impossible values are represented by the symbol NaN (not a number).
84. What is data import in R language?
The user can import data in R language. R commander GUI is used to type the commands, also known as Rcmdr, which is like a console.
85.Why the function anova(), cv.Im(), stepAIC()?
We can use the above functions for the following tasks:
- Anova(): Function is used to compare the nested models
- lm(): The function is defined under the DAAG package and is used fork-fold validation
- stepAIC(): The function is defined by the MASS package and can perform stepwise model selection under exact AIC.
86. Which data structure is used to store categorical variables?
R has a special data structure called “factor” to store categorical variables. It tells R that a variable is nominal or ordinal by making it a factor.
gender = c(1,2,1,2,1,2)
gender = factor(gender)
87. How to rename a variable?
In the example below, we are renaming variable var1 to variable1.
df = data.frame(var1=c(1:5))
colnames(df)[colnames(df) == ‘var1’] <- ‘variable1’
The rename() function in dplyr package can also be used to rename a variable.
df= rename(df, variable1=var1)
88. How to remove all the objects
89. How R handles missing values?
Missing values are represented by capital NA.
To create a new data without any missing value, you can use the code below :
df <- na.omit(mydata)
90. What are various ways to write la oop in R
There are primarily three ways to write a loop in R
- For Loop
- While Loop
- Apply Family of Functions such as Apply, Lapply, Sapply etc