

{"id":5171,"date":"2017-12-13T05:42:10","date_gmt":"2017-12-13T05:42:10","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=5171"},"modified":"2021-08-25T17:26:07","modified_gmt":"2021-08-25T11:56:07","slug":"r-programming-interview-questions","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/","title":{"rendered":"R Programming Interview Questions for aspiring Data Scientists [Updated]"},"content":{"rendered":"<p>Welcome back to R Programming Interview Questions and Answers Part 2.<\/p>\n<p>DataFlair has published a series of R programming interview questions and answers that will help both beginners and experienced of R and data science to crack their upcoming data scientists interview. Bookmark the links and practice the questions &#8211;<\/p>\n<ul>\n<li><a href=\"https:\/\/data-flair.training\/blogs\/r-interview-questions-and-answers\/\"><strong>R Language Interview Questions and Answers for Freshers<\/strong><\/a><\/li>\n<li><strong>R Language Interview Questions and Answers for Intermediate Level<\/strong><\/li>\n<li><a href=\"https:\/\/data-flair.training\/blogs\/r-data-science-interview-questions\/\"><strong>R Language Interview Questions and Answers for Experienced<\/strong><\/a><\/li>\n<\/ul>\n<p>Let&#8217;s continue to the second part &#8211; R programming interview questions and answers for data scientists. This part mainly focuses on R coding interview questions and technical interview questions. Now, you will not face any difficulty in your tech round. Do practice all the questions and get ready for the upcoming interviews.<\/p>\n<p>In between, if you feel you need to revise any concept you are not clear with you can comment below or check the<em><strong> <a href=\"https:\/\/data-flair.training\/blogs\/r-tutorials-home\/\">Free R Tutorials Library<\/a><\/strong><\/em><\/p>\n<h2>R Coding Interview Questions and Answers<\/h2>\n<p><strong>Q.1 What is f(3) where:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x &lt;- 7\r\nf &lt;- function(y) { x &lt;- 3; x^2 + g(y) }\r\ng &lt;- function(y) { y + x }<\/pre>\n<p><strong>Ans.<\/strong> The above-written code will return the result of 19. In f In f(3), x is 3, so x^2 is 6. Then, the value is passed to g(3), where x is globally scoped and hence y + x = 3 + 7 = 10. Hence, we obtain f(3) = 9 + 10 = 19 as the final answer.<\/p>\n<p><strong>Q.2 Given the IRIS dataset, consisting of a mix of continuous variables and categorical ones.<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71163\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg\" alt=\"plotting variables in R\" width=\"816\" height=\"382\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg 816w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-300x140.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-768x360.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-520x243.jpg 520w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/a><\/p>\n<p><strong>Where would you apply &#8211; <\/strong><\/p>\n<ul>\n<li><strong>Barplot<\/strong><\/li>\n<li><strong>Histogram<\/strong><\/li>\n<\/ul>\n<p><strong>Also, explain where do these two types of plots differ with their respective implementations.<\/strong><\/p>\n<p><strong>Ans.<\/strong> Histograms are used for plotting continuous variables. On the contrary, Barplots are used for plotting categorical variables. In the given data, Species column consists of categorical data whereas rest of the data consists of continuous one. We can plot a histogram for the feature Sepal.Width as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; ggplot(data = iris,aes(x=Sepal.Width))+geom_histogram(fill=\"steelblue\",col=\"red\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71164\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram.jpg\" alt=\"Histogram in R programming\" width=\"1292\" height=\"736\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram.jpg 1292w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-histogram-520x296.jpg 520w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\" \/><\/a><\/p>\n<p>Furthermore, for plotting a barplot, we write the following line of code &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; ggplot(data = iris,aes(x=Species))+geom_bar(fill=\"steelblue\",color = 'red') #DataFlair<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71165\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot.jpg\" alt=\"barplots in R\" width=\"1298\" height=\"742\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Barplot-520x297.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p><em><strong>Learn in detail about<a href=\"https:\/\/data-flair.training\/blogs\/bar-chart-in-r\/\"> Barplot and Histogram<\/a><\/strong><\/em><\/p>\n<p><strong>Q.3 Suppose you have to work on a dataset consisting of categorical variables. Let this dataset be iris which consists of the column \u201cSpecies\u201d being categorical in nature. You have to implement the XGBoost Algorithm. What problem would you face and how will you resolve it?<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71163\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg\" alt=\"plotting variables in R\" width=\"816\" height=\"382\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset.jpg 816w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-300x140.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-768x360.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-IRIS-dataset-520x243.jpg 520w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/a><\/p>\n<p><strong>Ans.<\/strong> The XGBoost Algorithm only works well with the numerical data. Considering that we have a categorical feature &#8211; \u201cSpecies\u201d in our dataset, we will first have to convert that into numerical form. This can be achieved by using dummy variables. We can implement this as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">library(dummies)\r\ndummy(iris$Species)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71166\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable.jpg\" alt=\"interview questions in R\" width=\"1296\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-Dummy-variable-520x297.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<p><strong>Q.4 In the same iris dataset, you have been assigned the task of identifying outliers. You must be able to provide a comprehensive glimpse of the dataset using a suitable visualisation. What method would you choose and why?<\/strong><\/p>\n<p><strong>Ans.<\/strong> Visualising Boxplot is an ideal method of identifying the outliers. The identification of outliers is important because through boxplots, one can obtain a comprehensive idea of the minimum, lower quartile (25th percentile), median (50th percentile), upper quartile (75th percentile), as well as the maximum of a continuous variable. This will help us to get an overall idea of how the data is, and if there are any outliers which may affect the fitting of our model.<\/p>\n<p><em><strong>Here is a detailed guide for <a href=\"https:\/\/data-flair.training\/blogs\/data-visualization-in-r\/\">Data Visualization with R<\/a><\/strong><\/em><\/p>\n<p>We can create our boxplot on the iris dataset as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">boxplot(Sepal.Length ~ Species, data=iris, main=\"Box Plot\", xlab=\"Species\", ylab=\"Sepal Length\", col = \"PaleGreen3\", border = \"darkgreen\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71162\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers.jpg\" alt=\"R coding interview questions\" width=\"1298\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boxplot-outliers-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p><strong>Q.5 Given a dataset, you wish to explore the variations that are present in the features. However, suppose that the dataset consists of 1000 features. It is not easy to represent all of these features in a single plot to gain an idea of the trends contained within. What will you do in this scenario? For simplicity of implementation, consider the mtcars dataset present in the R environment.<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71160\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset.jpg\" alt=\"Principle Component Analysis in R\" width=\"890\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset.jpg 890w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset-150x71.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset-300x142.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset-768x362.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset-520x245.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcars-dataset-720x340.jpg 720w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/a><\/p>\n<p><strong>Ans.<\/strong> This problem statement requires us to implement<em><strong><a href=\"https:\/\/data-flair.training\/blogs\/principal-components-and-factor-analysis-in-r\/\"> Principle Component Analysis<\/a><\/strong><\/em>. With the help of this algorithm, one can easily see the overall shape of the data. Through visualisation of the variations in the data, one can identify similar features as well as dissimilar features. In order to implement PCA on this dataset, we must first drop the \u2018vs\u2019 and \u2018am\u2019 variable as they are categorical in nature. We will then plot our PCA graph with rest of the dataset &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; pca &lt;- prcomp(mtcars[,c(1:7,10,11)], center = TRUE,scale. = TRUE)\r\n&gt; library(ggbiplot)\r\n&gt; ggbiplot(pca) #DataFlair<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71161\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R.jpg\" alt=\"plotting PCA graph in R\" width=\"1297\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R.jpg 1297w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/mtcarsPCA-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p><strong>Q6. How do correlated variables in a dataset affect the model performance? Given the \u2018boston\u2019 dataset provided by R, diagnose the model to improve its performance.<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71167\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset.jpg\" alt=\"R Interview questions\" width=\"1041\" height=\"498\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset.jpg 1041w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset-300x144.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset-768x367.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset-1024x490.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-boston-dataset-520x249.jpg 520w\" sizes=\"auto, (max-width: 1041px) 100vw, 1041px\" \/><\/a><\/p>\n<p><strong>Ans.<\/strong> While carrying out regression, it is assumed that the variables are not correlated to one another. If the variables are however, correlated then our model will suffer from the following problems.<\/p>\n<ul>\n<li>The parameters present in our model will become indeterminate.<\/li>\n<li>During model evaluation, the standard error of the estimated values will increase significantly.<\/li>\n<\/ul>\n<p>Furthermore, the solution of our regression model will become highly unstable. In order to compute multicollinearity present in our dataset, we make use of the Variance Inflation Score or VIF. This score measures the inflation caused to the correlation coefficient contributed by multicollinearity that is present in the model.<\/p>\n<p>To check for multicollinearity in our model. We will begin by splitting the boston dataset into training and test data.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; set.seed(123)\r\n&gt; sample_data &lt;- Boston$medv %&gt;%\r\n+ createDataPartition(p = 0.8, list = FALSE)\r\n&gt; training_data &lt;- Boston[sample_data, ]\r\n&gt; testing_data &lt;- Boston[-sample_data, ]\r\n&gt; #DataFlair<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71168\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset.jpg\" alt=\"R programming concepts for interview\" width=\"1296\" height=\"732\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset-300x169.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset-768x434.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset-1024x578.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/splitting-boston-dataset-520x294.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<p>In the next step, we will build a regression model and evaluate its accuracy.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71169\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model.jpg\" alt=\"regression in R programming\" width=\"1294\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model.jpg 1294w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regression-model-520x297.jpg 520w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/a><\/p>\n<p>Now, we will evaluate the VIF score for each variable<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">car::vif(corr_model)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71170\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score.jpg\" alt=\"R programming interview questions\" width=\"1298\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-vif-score-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p>From the VIF scores generated above, we observe that the tax variable has the highest score. Therefore, we will remove this variable and evaluate our model again.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; # Building the model without tax variable #DataFlair\r\n&gt; corr_model &lt;- lm(medv ~. -tax, data = training_data)\r\n&gt; # Generate Predictions\r\n&gt; prediction &lt;- corr_model %&gt;% predict(testing_data)\r\n&gt; # Model performance\r\n&gt; data.frame(\r\n+    RMSE = RMSE(prediction, testing_data$medv),\r\n+    R2 = R2(prediction, testing_data$medv)\r\n+ )<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71171\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R.jpg\" alt=\"R models\" width=\"1300\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R-1024x581.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/evaluating-model-in-R-520x295.jpg 520w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<p>From the above observation, we conclude that removing \u2018tax\u2019 variable does not affect the model much. Therefore, the model requires other areas of improvement to achieve a better score.<\/p>\n<p><strong>Q.7 What will be the output of this code? State the reason behind the flow of code execution. <\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">generic2 &lt;- function(x) UseMethod(\"generic1\")\r\ngeneric2_a1 &lt;- function(x) \"a1\"\r\ngeneric2_a2 &lt;- function(x) \"a2\"\r\ngeneric2_b1 &lt;- function(x) {\r\n  class(x) &lt;- \"a1\"\r\n  NextMethod()\r\n}\r\n\r\n\r\ngeneric2(structure(list(), class = c(\"b1\", \"a2\")))<\/pre>\n<p><strong>Ans.<\/strong> After we run the above code, following things happen in the code &#8211;<\/p>\n<ul>\n<li>The objects of class b1 and a2 get passed to generic(). This prompts the R code to search for the method we pass an object of class b and a2 to generic2(), which prompts R to look for a method generic2_b1()<\/li>\n<li>The generic2_b1() method changes class the class to a1 and then the NextMethod().<\/li>\n<li>Normally, one would assume that R will call genericOne would think that this will lead R to call generic2_a1(). However, the NextMethod() does not work with the class attribute but instead makes use of the global variable (.Class) that monitors next method to be called.<\/li>\n<\/ul>\n<p>Therefore, in the above code, generic2_a2() is called.<\/p>\n<p><strong>Q.8 Will the following code return any error? State the reason behind your answer.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">val &lt;- numeric()\r\nresult &lt;- vector(\"list\", length(val))\r\nfor (index in 1:length(val)) {\r\n  result[index] &lt;- val[index] ^ 2\r\n}\r\nresult<\/pre>\n<p><strong>Ans.<\/strong> The code will not yield any error. In the above code, the index iterates over the vector val having a length of 0. The loop is taken from index = 1 to index = 0. The \u2018:\u2019 in this case counts down. During the first iteration, val[1] will have an NA indexing for the atomic value. This resulting NA will have an empty length give the result[1] &#8211; \u201cout of bounds indexing for the lists\u201d<\/p>\n<p>In the following iteration, val[0] will provide us with the numeric(0) index as a returned value. Squaring the value will not have any effect and as a result, numeric(0) is assigned to result[0]. When a vector of length 0 is assigned to a subset of length 0, it does not alter anything. The code will execute as it step involves valid R operations.<\/p>\n<p><strong>Q.9 Import the diamonds dataset that is provided by the ggplot package. Your aim is to create a scatter plot of price vs depth. How will you proceed to find the depth value where most diamonds are found?<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71156\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data.jpg\" alt=\"importing dataset in R\" width=\"848\" height=\"327\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data.jpg 848w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data-150x58.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data-300x116.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data-768x296.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-data-520x201.jpg 520w\" sizes=\"auto, (max-width: 848px) 100vw, 848px\" \/><\/a><\/p>\n<p><strong>Ans.<\/strong> Using ggplot2 package, we will plot the scatterplot of the variable depth vs price as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ggplot(data = diamonds, aes(x = depth,y = price)) +\r\n+ geom_point(alpha= 0.5) #DataFlair<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71158\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1.jpg\" alt=\"ggplot2 package\" width=\"1295\" height=\"734\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1-768x435.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1-1024x580.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot1-520x295.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p>We can observe that the diamonds are densely concentrated in an area around 60. However, this does not give us a precise area where the highest concentration of diamonds of located. Therefore, we change the transparency of the points to be 1\/100th of their original and mark the x-axis at every 2 units.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ggplot(data = diamonds, aes(x = depth,y = price)) +\r\n+ geom_point(alpha= 0.01) +\r\n+ scale_x_continuous(breaks = seq(0,80,2))<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71159\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2.jpg\" alt=\"visualization in R \" width=\"1294\" height=\"737\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2.jpg 1294w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/diamond-scatterplot2-520x296.jpg 520w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/a><\/p>\n<p>From the above visualisation, we observe that the highest concentration of diamonds is between 60-64.<\/p>\n<p><em><strong>Don&#8217;t miss to revise the important <a href=\"https:\/\/data-flair.training\/blogs\/r-packages-tutorial\/\">concept of R packages<\/a> for your upcoming data science interviews<\/strong><\/em><\/p>\n<p><strong>Q.10 What are some of the errors present in the code below? Fix these errors with their respective correct answers.<\/strong><\/p>\n<ul>\n<li>iris[iris$Sepal.Length = 5, ]<\/li>\n<li>iris[-1:5, ]<\/li>\n<li>iris[iris$Sepal.Length &lt;= 5]<\/li>\n<\/ul>\n<p><strong>Ans.<\/strong> The correct versions of these codes are as follows &#8211;<\/p>\n<ul>\n<li>iris[iris$Sepal.Length == 5, ]<\/li>\n<li>iris[-(1:5), ]<\/li>\n<li>iris[iris$Sepal.Length &lt;= 5, ]<\/li>\n<\/ul>\n<p><strong>Q.11 Suppose that you want to access a graphics device, run the code on it and then close the device. How will you carry out this procedure in the form of a function? The file that you want to save is a pdf file &#8211; \u2018data.pdf\u2019<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">PDF_plot &lt;- function(code) {\r\n  pdf(\"data.pdf\")\r\n  on.exit(dev.off(), add = TRUE)\r\n  code\r\n}<\/pre>\n<p><strong>Q.12 How will you convert the following code into its corresponding prefix form?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">2 + 3 + 4\r\n2 + (3 + 4)\r\nif (length(x) &lt;= 5) x[[5]] else x[[n]]<\/pre>\n<p><strong>Ans.\u00a0<\/strong>Let us rewrite these expressions to match the given code syntax. Since the prefix functions pre-define the order of execution, the parentheses can be therefore, omitted in the second expression.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">`+`(`+`(2, 3), 4)\r\n\r\n`+`(2, `(`(`+`(3, 4)))\r\n`+`(2, `+`(3, 4))<\/pre>\n<p>Important Tip!! If you want to crack your next data science interview so along with these top R programming Interview Questions and Answers you need to practice some R projects.<\/p>\n<p><em><strong>DataFlair has published many projects, practice here &#8211; <a href=\"https:\/\/data-flair.training\/blogs\/data-science-projects-code\/\">Top R projects for Data Science interview<\/a><\/strong><\/em><\/p>\n<p><strong>Q.13 How will you create an R6 class that lets you have a bank account you to access your balance, store deposit as well as withdraw money?<\/strong><\/p>\n<p><strong>Ans.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">BankAccount &lt;- R6Class(\"BankAccount\", list(\r\nbal = 0,\r\namount_deposit = function(dpt = 0) {\r\n  self$bal = self$bal + dpt\r\n  invisible(self)\r\n},\r\nwithdraw = function(amount_draw) {\r\n  self$bal = self$bal - amount_draw\r\n  invisible(self)\r\n}\r\n))<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71153\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class.jpg\" alt=\"R coding interview questions\" width=\"1292\" height=\"724\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class.jpg 1292w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-150x84.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-300x168.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-768x430.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-1024x574.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-520x291.jpg 520w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\" \/><\/a><\/p>\n<p>Let us test this by creating an instance and getting a balance.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">new_account &lt;- BankAccount$new()\r\nnew_account$bal\r\nnew_account$\r\n amount_deposit(10)$\r\n withdraw(20)$\r\n  bal<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71154\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance.jpg\" alt=\"questions asked in data scientist interview\" width=\"1300\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance-1024x581.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R6-Class-Instance-520x295.jpg 520w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<p><strong>Q.14 How will you create an R6 class that manages the current working directory? This class should have $get and $set() methods.<\/strong><\/p>\n<p><strong>Ans.<\/strong> The R6 class for managing the current working directory be implemented as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">WorkingDirectory &lt;- R6Class(\"WorkingDirectory\", list(\r\n  get_directory = function() {\r\n    getwd()\r\n},\r\nset_directory = function(value) {\r\n    setwd(value)\r\n}\r\n))<\/pre>\n<p><strong>Q.15 What takes place when you alter the levels of a factor given below?<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">fac &lt;- factor(letters)\r\nlevels(fac) &lt;- rev(levels(fac))<\/pre>\n<p><strong>Ans.<\/strong> The various integer values that lie in the factor remain the same. However, the levels get altered giving the data a changed appearance.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; fac &lt;- factor(letters[1:10])\r\n&gt; levels(fac) #DataFlair\r\n&gt; fac\r\n&gt; as.integer(fac)\r\n&gt; levels(fac) &lt;- rev(levels(fac))\r\n&gt; levels(fac)\r\n&gt; fac\r\n&gt; as.integer(fac)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71172\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R.jpg\" alt=\"R data science interview questions\" width=\"1290\" height=\"736\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R.jpg 1290w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/Factors-in-R-520x297.jpg 520w\" sizes=\"auto, (max-width: 1290px) 100vw, 1290px\" \/><\/a><\/p>\n<p><strong>Q16. Suppose you have a character vector containing the strings as follows &#8211;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">(string1 &lt;- c(\"a\", \"ab\", \"adb\", \"addb\", \"adddb\", \"adddb\"))<\/pre>\n<p><strong>You want to utilize a regex operation that would match the strings for the different variations in the pattern \u2018adb\u2019. You have to perform pattern matching in two ways &#8211; <\/strong><\/p>\n<ul>\n<li><strong>For atleast 1 time<\/strong><\/li>\n<li><strong>For atleast 0 time<\/strong><\/li>\n<\/ul>\n<p><strong>How will you carry out this operation?<\/strong><\/p>\n<p><strong>Ans.<\/strong> In order to obtain the two outputs, we will make use of the grep() function. This function takes the regex as first argument and input vector as its second argument. In this case, we will pass value = TRUE as we want the grep to return the vector being a copy of the actual elements in the input vector that can be matched. The two regex operations we will utilize for obtaining the desired output are &#8211;<\/p>\n<ul>\n<li>ad*b<\/li>\n<li>ad+b<\/li>\n<\/ul>\n<p>These two operations differ in their quantifier that defines how many times an object must be repeated. The \u2018*\u2019 quantifier would match the repetition atleast 0 times and the \u2018+\u2019 quantifier would perform it atleast 1 time. Then, we will implement this in code as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">grep(\"ad*b\", string1, value = TRUE)\r\n\r\ngrep(\"ad+b\", string1, value = TRUE)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71150\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R-.jpg\" alt=\"R programming interview questions and answers \" width=\"1295\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R-.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R--150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R--300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R--768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R--1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/regex-operation-in-R--520x297.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p style=\"text-align: center\"><em><strong><a href=\"https:\/\/data-flair.training\/blogs\/r-programming-functions\/\">R Functions<\/a><\/strong><\/em> &#8211; <em><strong>A very helpful article for R programming interview questions\u00a0<\/strong><\/em><\/p>\n<p><strong>Q.17 You have a task of finding names of all the .csv files in the repository. How will you carry this out using the regex operation? These csv files are stored in the following pattern &#8211;<\/strong><\/p>\n<p><strong>[1] &#8220;birds.csv&#8221; &#8220;boston.csv&#8221; &#8220;data.csv&#8221; &#8220;grass.csv&#8221; &#8220;table.csv&#8221;<\/strong><\/p>\n<p><strong>Ans.<\/strong> In this, we will make use of the combination of two regex quantifiers &#8211; \u2018.\u2019 and \u2018*\u2019. The \u2018.\u2019 quantifier returns the match found in any single character. We will create a character variable \u2018csvlist\u2019 and use the list.files() function with the pattern = \u201c.*.csv\u201d as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">csvlist = list.files(pattern = \".*.csv\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71149\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations.jpg\" alt=\"R interview questions on regex operations\" width=\"1294\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations.jpg 1294w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-regex-operations-520x298.jpg 520w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/a><\/p>\n<p><strong>Q.18 Suppose that you have string as follows &#8211;<\/strong><\/p>\n<p><strong>data_string &lt;- &#8220;I learn Big Data for 4 hours daily with DataFlair&#8221;<\/strong><\/p>\n<p><strong>You have to perform following operations using various regex sequences &#8211;<\/strong><\/p>\n<ul>\n<li><strong>Match the digit 4 and replace it with a dash \u2018_\u2019<\/strong><\/li>\n<li><strong>Replace the non-digit part of the string with \u2018_\u2019<\/strong><\/li>\n<li><strong>Replace the non-word character in string with \u2018&amp;<\/strong><\/li>\n<\/ul>\n<p><strong>Ans.<\/strong><\/p>\n<p>1. For matching the digit and replacing it with \u2018_\u2019, we will make use of the gsub() and regmatch() function as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">gsub(pattern = \"\\\\d+\",replacement = \"_\",x = data_string) \r\nregmatches(data_string,regexpr(pattern = \"\\\\d+\",text = data_string))<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71148\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash.jpg\" alt=\"interview questions on R\" width=\"1298\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash-1024x582.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replacing-digit-with-dash-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p>2. To match the non-digit part of the string and replace it with \u2018_\u2019, we will use the \\D sequence to match the non-digit part of our string and replace it with \u2018_\u2019.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">gsub(pattern = \"\\\\D+\",replacement = \"_\",x = data_string)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71147\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash.jpg\" alt=\"R coding interview questions\" width=\"1295\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/replace-non-digit-with-dash-520x296.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p>3. To match the non-word character and replace it with \u2018&amp;\u2019, we will use the sequence \\W as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; gsub(pattern = \"\\\\W\",replacement = \"&amp;\",x = data_string)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71146\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R-.jpg\" alt=\"R string concepts for interview\" width=\"1295\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R-.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R--150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R--300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R--768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R--1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/string-in-R--520x296.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p><strong>Q.19 For a given string, you have to extract all the email addresses that are contained in it.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">email &lt;- c(\"My email is abc@dataflair.com\",\"my email address is def@datalfair.com\",\"John Wayne\",\"Clint Eastwood\")<\/pre>\n<p><strong>Ans.<\/strong> To carry out this operation, we will make use of the POSIX class. In particular, we will use the [[:alnum:]] and [[:alpha:]] classes. The alnum class matches the alphanumeric characters whereas alpha class matches the letters.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; email &lt;- c(\"My email is abc@dataflair.com\",\"my email address is def@datalfair.com\",\"John Wayne\",\"Clint Eastwood\")\r\n&gt; unlist(regmatches(x = email, gregexpr(pattern = \"[[:alnum:]]+\\\\@[[:alpha:]]+\\\\.com\",text = email)))<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71145\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R.jpg\" alt=\"R technical questions\" width=\"1295\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/extracting-email-address-in-R-520x297.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p><strong>Q.20 Suppose you have to deal with a dataset. In this case, we will use the USArrests dataset provided by R.<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71144\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming.jpg\" alt=\"R Interview preparations\" width=\"522\" height=\"441\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming.jpg 522w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming-150x127.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming-300x253.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/dataset-for-R-programming-520x439.jpg 520w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/a><\/p>\n<p><strong>Before you proceed ahead with the model implementation. You have to perform data transformation in the following ways &#8211;<\/strong><\/p>\n<ul>\n<li><strong>Abbreviate the names of states. <\/strong><\/li>\n<li><strong>Select the states that contain the letter \u2018b\u2019<\/strong><\/li>\n<li><strong>Count the frequency of the vowels in and plot their frequency distribution plot. <\/strong><\/li>\n<\/ul>\n<p><strong>Ans.<\/strong><br \/>\nThere are two ways to abbreviate names of the states &#8211;<\/p>\n<ul>\n<li>Firstly, we can use the substr() function to limit the names of our states to a length of 4.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">substr(x = USstates, start = 1, stop = 4)<\/pre>\n<ul>\n<li>Secondly, we can use the abbreviate() function as follows &#8211;<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">abbreviate(USstates)<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71173\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R.jpg\" alt=\"R programming interview questions\" width=\"1295\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/abbreviating-functions-in-R-520x297.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p>To select the states containing letter \u201cb\u201d, we will use the grep function as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">grep(pattern = \"b\", x = USstates, value = TRUE)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71142\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states.jpg\" alt=\"using grep function in R \" width=\"1292\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states.jpg 1292w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states-1024x587.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/selecting-states-520x298.jpg 520w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\" \/><\/a><\/p>\n<p>To count the frequency of vowels, we will write the following code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">vowel = c(\"a\", \"e\", \"i\", \"o\", \"u\")\r\nfreq_vowel = vector(mode = \"integer\", length = 5)\r\nfor (index in seq_along(vowel)) {\r\n    num_total = str_count(tolower(states), vowel[index])\r\n    [index] = sum(num_total)\r\n}\r\nnames(freq_vowel) = vowel #DataFlair\r\nfreq_vowel<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71141\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels.jpg\" alt=\"R concepts for interview preparations\" width=\"1295\" height=\"735\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels-1024x581.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/count-frequency-of-vowels-520x295.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p>Then, we will plot a histogram to count the frequency of vowels occurring in the states.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">barplot(num_vowels, main = \"Number of vowels in USA States names\", border = NA, ylim = c(0, 80))<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71174\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R.jpg\" alt=\"R interview questions and answers\" width=\"1296\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R.jpg 1296w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/plotting-histogram-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/a><\/p>\n<p>This type of R programming question is mostly asked for interview. Practice more such questions.<\/p>\n<p><strong>Q 21. What conditions hold true in a stationary time-series analysis? Given the dataset \u2018EuStockMarkets\u2018, how will you impose these conditions on it?<\/strong><\/p>\n<p><strong>Ans.<\/strong> If the following conditions hold true, then the time-series model is said to be stationary &#8211;<\/p>\n<ul>\n<li>The average value of the time-series model is constant with the passage of time. Therefore, the trend component will be void.<\/li>\n<li>The model variance does not increment over time.<\/li>\n<li>The effect of seasonality is negligible.<\/li>\n<\/ul>\n<p>Therefore, a stationary time-series model does not have a trend or seasonal pattern making it look similar to the white noise. This is irrespective of the observed time intervals. We can impose these conditions by extracting the trends, seasonality and errors as follows &#8211;<\/p>\n<p>The decompose() function as well as the forecast::stl() function can split the time-series model into seasonality, error and trend component.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; time_data &lt;- EuStockMarkets[, 1]\r\n&gt; model_decomposition &lt;- decompose(time_data, type=\"mult\")\r\n&gt; plot(model_decomposition)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71139\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R.jpg\" alt=\"Timeseries analysis in R Interview\" width=\"1295\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-in-R-520x298.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p>We can also use the stl() function as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; stlRes &lt;- stl(time_data, s.window = \"periodic\") \r\n&gt; stlRes #DataFlair<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71140\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis.jpg\" alt=\"time-series model - R programming\" width=\"1297\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis.jpg 1297w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/timeseries-analysis-520x296.jpg 520w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p><strong>Q.22 You had mentioned White Noise in your previous explanation of stationary time-series analysis. How will you simulate White Noise in R?<\/strong><\/p>\n<p><strong>Ans.<\/strong> The white noise model is an elementary time-series model. It is a type of stationary process.<br \/>\nThe white noise model consists of:<\/p>\n<ul>\n<li>A fixed constant mean<\/li>\n<li>A fixed constant variance<\/li>\n<li>Lack of correlation over time.<\/li>\n<\/ul>\n<p>We can simulate a white noise model in R as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; ts.wn &lt;- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 100) #DataFlair\r\n&gt; ts.plot(ts.wn)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71138\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R.jpg\" alt=\"R programming practice questions\" width=\"1297\" height=\"736\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R.jpg 1297w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R-1024x581.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/white-noise-in-R-520x295.jpg 520w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p><strong>Q.23 Explain the differences between Autocorrelation and Partial Correlation by giving an implementation example of each.<\/strong><\/p>\n<p><strong>Ans.<\/strong> The correlation of a Time Series model with the delays of itself. It is an important metric due to the following reasons &#8211;<\/p>\n<ul>\n<li>Autocorrelation informs us if the previous states have any form of influence on the current state. If the autocorrelation ranges over the blue line, then we find that particular lag shares some correlation with the present series. For example, in the case of the chart of AirPassengers, we find that the top-left chart exhibits significant autocorrelation for the lags that are depicted on the x-axis.<\/li>\n<li>We use it for determining of the time-series has a stationary nature or not. A Stationary time-series will cause the autocorrelation to fall to 0 quickly and gradually for a non-stationary series.<\/li>\n<\/ul>\n<p>In the case of a partial correlation, the time-series has a correlation with its own lag. This takes place with the linear dependence of all the tags removed between them.<\/p>\n<p>We can implement the autocorrelation as well as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Partial_correlation\">partial correlation<\/a> plot as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; par(mfrow = c(1,3))\r\n&gt; autocorr &lt;- acf(AirPassengers) #Autocorrelation\r\n&gt; partialcorr &lt;- pacf(AirPassengers)\r\n&gt; crosscorr &lt;- ccf(mdeaths, fdeaths, ylab = \"cross-correlation\") #DataFlair\r\n&gt; head(crosscorr[[1]])<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71136\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R.jpg\" alt=\"R programming - correlation\" width=\"1297\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R.jpg 1297w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/auto-correlation-partial-correlation-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1297px) 100vw, 1297px\" \/><\/a><\/p>\n<p>We obtain the following plots that are a result of our above-written code &#8211;<\/p>\n<div id=\"attachment_71137\" style=\"width: 949px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-71137\" class=\"wp-image-71137 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming.jpg\" alt=\"R programming Interview Questions\" width=\"939\" height=\"351\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming.jpg 939w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming-150x56.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming-300x112.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming-768x287.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/correlation-Plot-R-programming-520x194.jpg 520w\" sizes=\"auto, (max-width: 939px) 100vw, 939px\" \/><\/a><p id=\"caption-attachment-71137\" class=\"wp-caption-text\">R Programming Interview Questions<\/p><\/div>\n<p><strong>Q.24 What do you mean by deseasonalizing a time-series. How can you implement this in R?<\/strong><\/p>\n<p><strong>Ans.<\/strong> In order to gain insights about the time series model, we make use of deseasonalizing. It helps to model our data without causing any seasonal effects.<\/p>\n<p>We can deseasonalize a time-series model in the following steps:<\/p>\n<ul>\n<li>Decomposing the time-series using forecast::stl() function.<\/li>\n<li>Using seasadj() function from the forecast package.<\/li>\n<\/ul>\n<p>Using the seasadj package, one can adjust the seasoning by removing the seasoning components.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">library(forecast)\r\nlibrary(ggplot2)\r\ndata_decomp &lt;- stl(log(AirPassengers), s.window=\"periodic\")\r\nap.sea &lt;- exp(seasadj(data_decomp))\r\nautoplot(cbind(AirPassengers, SeasonallyAdjusted=ap.sea)) +\r\nxlab(\"Year\") + ylab(\"Number of passengers in thousands\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71135\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R.jpg\" alt=\"Most asked R interview questions\" width=\"1295\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/deseasonalizing-a-timeseries-in-R-520x297.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p><strong>Q.25 What will be the result of this following code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">withCallingHandlers( # (1)\r\n    message = function(dnc) message(\"d\"),\r\n    withCallingHandlers( # (2)\r\n      message = function(dnc) message(\"c\"),\r\n      message(\u201ca\u201d)\r\n    )\r\n)<\/pre>\n<p><strong>Ans.<\/strong> When the message(\u201ca\u201d) is run, it is caught by (1). It then places the call to the message (\u201cc\u201d) which in turn gets caught by (2) eventually calling the message (\u201cd\u201d). Since message(\u201cd\u201d) isn\u2019t caught, we see \u2018d c\u2019 on the output. This is followed by \u2018a\u2019. We get another \u2018d\u2019 before we obtain \u2018a\u2019 because we have not handled the message. Therefore, it comes up to the outer calling handler.<\/p>\n<p><strong>Q.26 What is a generalized linear model? How can you implement this in R?<\/strong><\/p>\n<p><strong>Ans.<\/strong> An extension of Linear Regression is the <a href=\"https:\/\/data-flair.training\/blogs\/generalized-linear-models-in-r\/\"><em><strong>Generalized Linear Models<\/strong><\/em><\/a>. They allow the dependent variable to be far from normal. There are three assumptions that a general model makes.<\/p>\n<ul>\n<li>Residuals are mutually independent. Residuals are independent of each other.<\/li>\n<li>They have normal distribution.<\/li>\n<li>The parameters x and y of the model possess a linear relationship.<\/li>\n<\/ul>\n<p>A Generalized Linear Model creates an extension of the last two assumptions. The generalization of the possible distributions that residuals share are to a family called exponential family.<\/p>\n<p>We can implement Generalized Linear Model in R using the lm() function as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#Author DataFlair\r\ndata(cars)\r\nhead(cars)\r\n\r\nscatter.smooth(x=cars$speed, y=cars$dist, main=\"Dist ~ Speed\", col = \"blue\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71129\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R.jpg\" alt=\"R interview questions - GLM\" width=\"1295\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/glm-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">GLM &lt;- lm(dist ~ speed, data=cars)\r\nprint(GLM)\r\nsummary(GLM)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71130\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model.jpg\" alt=\"R technical interview questions - GLM\" width=\"1294\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model.jpg 1294w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model-300x172.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model-768x440.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model-1024x586.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/R-generalized-linear-model-520x298.jpg 520w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/a><\/p>\n<p><strong>Q.27 What is a Random Forest algorithm? How can you build an evaluate Random Forest in R?<\/strong><\/p>\n<p><strong>Ans.<\/strong> These are a type of ensemble learning methods that we can use for classification as well as regression. Furthermore,<em><strong><a href=\"https:\/\/data-flair.training\/blogs\/random-forest-in-r\/\"> Random Forests<\/a><\/strong><\/em> perform these tasks using the underlying decision trees. The model constructs them during training time to display the output which can be classification or regression. We can implement our random forest in R using the randomForest package as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">library(randomForest)\r\nset.seed(4500)\r\ndata(mtcars)\r\nRF.mtcars &lt;- randomForest(mpg ~ ., data=mtcars, ntree=1000, keep.forest=FALSE, importance=TRUE)\r\nimportance(RF.mtcars)\r\nimportance(RF.mtcars, type=1)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71131\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1.jpg\" alt=\"Random forest in R \" width=\"1300\" height=\"719\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1.jpg 1300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1-150x83.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1-300x166.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1-768x425.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1-1024x566.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-1-520x288.jpg 520w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71132\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2.jpg\" alt=\"R programming - random forest \" width=\"1298\" height=\"555\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2-150x64.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2-300x128.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2-768x328.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2-1024x438.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/random-forest-2-520x222.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p><strong>Q.28 What is Ward\u2019s Hierarchical Clustering? Implement this in R using the USArrests dataset.<\/strong><\/p>\n<p><strong>Ans.<\/strong> We use Ward\u2019s method for hierarchical cluster analysis. Its minimum variance method is a special case of the objective function approach. In this, we make use of a general agglomerative hierarchical clustering approach in which the criterion for selecting pair of clusters combine at each step based on the ideal value of the objective function. We can implement this algorithm as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">data &lt;- USArrests\r\ndata &lt;- na.omit(data)\r\ndata &lt;- scale(data)\r\ndissim &lt;- dist(data, method = \"euclidean\")\r\nclust_fit &lt;- hclust(dissim, method = \"ward.D\")\r\nplot(clust_fit, cex = 0.6, hang = -1)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71133\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R.jpg\" alt=\"R programming interview questions on hierarchical clustering\" width=\"1294\" height=\"739\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R.jpg 1294w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R-768x439.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R-1024x585.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/hierarchial-clustering-in-R-520x297.jpg 520w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/a><\/p>\n<p><strong>Q.29 Suppose in a survey, IQ scores of school children were measured. The IQ scores were distributed with a mean of 100 and a standard deviation of 15. You want to find the proportion of children having IQ between 80 and 120. How can you solve this using R?<\/strong><\/p>\n<p><strong>Ans.<\/strong> We can solve this problem by writing the following code to create visualisation of the normal graph as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; mean=100; std=15\r\n&gt; lbound=80; ubound=120\r\n&gt;\r\n&gt; input &lt;- seq(-5,5,length=100)*std + mean\r\n&gt; hx &lt;- dnorm(input,mean,std)\r\n&gt;\r\n&gt; plot(input, hx, type=\"n\", xlab=\"IQ Values\", ylab=\"\",\r\n+      main=\"Normal Distribution\", axes=FALSE)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71134\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R.jpg\" alt=\"data visualization in R - data science interview preparation \" width=\"1298\" height=\"738\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R-1024x582.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/data-visualization-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt; i &lt;- input &gt;= lbound &amp; input &lt;= ubound\r\n&gt; lines(input, hx)\r\n&gt; polygon(c(lbound,input[i],ubound), c(0,hx[i],0), col=\"red\")\r\n&gt;\r\n&gt; area &lt;- pnorm(ubound, mean, std) - pnorm(lbound, mean, std)\r\n&gt; result &lt;- paste(\"P(\",lbound,\"&lt; IQ &lt;\",ubound,\") =\",\r\n+                 signif(area, digits=3))\r\n&gt; mtext(result,3)\r\n&gt; axis(1, at=seq(40, 160, 20), pos=0)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71152\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R.jpg\" alt=\"R programming interview questions\" width=\"1295\" height=\"736\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R-1024x582.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/normal-distribution-in-R-520x296.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><\/p>\n<p><strong>Q.30 How will you carry out bootstrapping of a single statistic (k = 1) in R? Take the example of the mtcars dataset and further replicate the confidence interval by 1000.<\/strong><\/p>\n<p><strong>Ans.<\/strong> We can perform the <em><strong><a href=\"https:\/\/data-flair.training\/blogs\/bootstrapping-in-r\/\">bootstrapping<\/a><\/strong><\/em> of a single statistic by replicating the confidence interval by 10000 as follows &#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">library(boot)\r\n# function to obtain R-Squared from the data\r\nrsquared &lt;- function(formula, data, indices) {\r\n    dsample &lt;- data[indices,] #Selecting sample\r\n    model.fit &lt;- lm(formula, data=dsample)\r\n    return(summary(fit)$r.square)\r\n}\r\n# Performing bootstrap with 1000 replications\r\noutput &lt;- boot(data=mtcars, statistic=rsq,\r\n+               R=1000, formula=mpg~wt+disp)\r\n\r\n# view output\r\noutput<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-71126\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1.jpg\" alt=\"r technical interview questions\" width=\"1298\" height=\"642\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1.jpg 1298w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1-150x74.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1-300x148.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1-768x380.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1-1024x506.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap1-520x257.jpg 520w\" sizes=\"auto, (max-width: 1298px) 100vw, 1298px\" \/><\/a><\/p>\n<p>R programming interview questions<\/p>\n<div id=\"attachment_71127\" style=\"width: 1305px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-71127\" class=\"size-full wp-image-71127\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2.jpg\" alt=\"r interview questions for data scientist\" width=\"1295\" height=\"735\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2.jpg 1295w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2-300x170.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2-768x436.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2-1024x581.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap2-520x295.jpg 520w\" sizes=\"auto, (max-width: 1295px) 100vw, 1295px\" \/><\/a><p id=\"caption-attachment-71127\" class=\"wp-caption-text\">Bootstrapping &#8211; R programming interview questions<\/p><\/div>\n<p>Now, we proceed ahead to plot our output and display our confidence interval as follows<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plot(output)\r\nboot.ci(output, type=\"bca\")<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-71128\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3.jpg\" alt=\"R technical Interview questions \" width=\"1292\" height=\"735\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3.jpg 1292w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3-150x85.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3-768x437.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3-1024x583.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/10\/bootstrap3-520x296.jpg 520w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\" \/><\/a><\/p>\n<p>I hope after practicing the above R programming interview questions and answers now you are more confident to face your next data science interview.<\/p>\n<p>Are there any R programming interview questions in which you faced difficulty? If yes. then comment below. DataFlair is ready to help you.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2188,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Partial_correlation&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250822010703\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Partial_correlation&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-11 02:10:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-25 16:14:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 13:37:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 00:46:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 19:00:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 17:40:25&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-06-20 16:34:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-30 03:18:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-08 02:58:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-12 15:02:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-16 01:09:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-21 09:40:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-26 09:44:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-02 07:27:10&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-08-02 07:27:10&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back to R Programming Interview Questions and Answers Part 2. DataFlair has published a series of R programming interview questions and answers that will help both beginners and experienced of R and data&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":71177,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[21252,11209,21257,11244,21253],"class_list":["post-5171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","tag-r-data-science-interview-questions","tag-r-interview-questions","tag-r-language-interview-questions","tag-r-programming-interview-questions","tag-r-technical-interview-questions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>R Programming Interview Questions for aspiring Data Scientists [Updated] - DataFlair<\/title>\n<meta name=\"description\" content=\"R programming interview questions and answers - practice these most asked technical questions and prepare yourself for the upcoming data science interview\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R Programming Interview Questions for aspiring Data Scientists [Updated] - DataFlair\" \/>\n<meta property=\"og:description\" content=\"R programming interview questions and answers - practice these most asked technical questions and prepare yourself for the upcoming data science interview\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-13T05:42:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-25T11:56:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"22 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"R Programming Interview Questions for aspiring Data Scientists [Updated] - DataFlair","description":"R programming interview questions and answers - practice these most asked technical questions and prepare yourself for the upcoming data science interview","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/","og_locale":"en_US","og_type":"article","og_title":"R Programming Interview Questions for aspiring Data Scientists [Updated] - DataFlair","og_description":"R programming interview questions and answers - practice these most asked technical questions and prepare yourself for the upcoming data science interview","og_url":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2017-12-13T05:42:10+00:00","article_modified_time":"2021-08-25T11:56:07+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"22 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"R Programming Interview Questions for aspiring Data Scientists [Updated]","datePublished":"2017-12-13T05:42:10+00:00","dateModified":"2021-08-25T11:56:07+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/"},"wordCount":3347,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg","keywords":["R data science interview questions","R Interview Questions","R language interview questions","R Programming Interview Questions","r technical interview questions"],"articleSection":["R Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/","url":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/","name":"R Programming Interview Questions for aspiring Data Scientists [Updated] - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg","datePublished":"2017-12-13T05:42:10+00:00","dateModified":"2021-08-25T11:56:07+00:00","description":"R programming interview questions and answers - practice these most asked technical questions and prepare yourself for the upcoming data science interview","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2017\/12\/top-R-programming-interview-questions.jpg","width":802,"height":420,"caption":"top R programming interview questions"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/r-programming-interview-questions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"R Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/r\/"},{"@type":"ListItem","position":3,"name":"R Programming Interview Questions for aspiring Data Scientists [Updated]"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=5171"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5171\/revisions"}],"predecessor-version":[{"id":71517,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5171\/revisions\/71517"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/71177"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=5171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=5171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=5171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}