Most answered questions in Data Analytics

0 votes
1 answer

Get list of rownames as values after aggregating a dataframe

You can use reshape2 library: library(reshape2) data <- read.table(text="type ...READ MORE

Apr 17, 2018 in Data Analytics by Sahiti
• 6,370 points
465 views
0 votes
1 answer

Reshape data from long to wide format

You can use the reshape function reshape(data, idvar ...READ MORE

Apr 17, 2018 in Data Analytics by nirvana
• 3,130 points
524 views
0 votes
1 answer

How to drop factor levels in a subsetted data frame?

You can use factor(ff) to drop levels ...READ MORE

Apr 17, 2018 in Data Analytics by kappa3010
• 2,090 points

edited Apr 17, 2018 by kappa3010 5,054 views
0 votes
1 answer

Is there any way to check for missing packages and install them in R?

There are 2 options: Either you can use ...READ MORE

Apr 17, 2018 in Data Analytics by nirvana
• 3,130 points
693 views
0 votes
1 answer

Plot two variables as lines on the same graph using ggplot

If you have small number of variables, ...READ MORE

Apr 17, 2018 in Data Analytics by kappa3010
• 2,090 points
4,710 views
0 votes
1 answer

Unload a package without restarting R

Try the below option: detach("package:vegan", unload=TRUE) NOTE: You can ...READ MORE

Apr 17, 2018 in Data Analytics by DataKing99
• 8,240 points
3,603 views
0 votes
1 answer

Check if the object(variable) is defined in R

You can use the exists(): > exists("toFindUnknown") [1] FALSE > ...READ MORE

Apr 17, 2018 in Data Analytics by Sahiti
• 6,370 points
610 views
0 votes
1 answer

How to check if a directory exists and how to create and create if doesn't exist?

You can use showWarnings = FALSE NOTE:  showWarnings ...READ MORE

Apr 17, 2018 in Data Analytics by DataKing99
• 8,240 points
2,188 views
0 votes
1 answer

Find length of string in R

You can try nchar > nchar("fast") [1] 4 > set.seed(10) > ...READ MORE

Apr 17, 2018 in Data Analytics by DataKing99
• 8,240 points
689 views
0 votes
1 answer

Read command line parameters from an R script

Here's an example to explain : Two files ...READ MORE

Apr 17, 2018 in Data Analytics by kappa3010
• 2,090 points
3,379 views
0 votes
1 answer

How can I measuring running time of R Code ?

5 ways to measure running time of ...READ MORE

Apr 17, 2018 in Data Analytics by anonymous
12,272 views
0 votes
1 answer

How to plot side-by-side Plots with ggplot2 in R?

By Using gridExtra library we can easily ...READ MORE

Apr 16, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by MD 8,531 views
0 votes
1 answer

Save a plot as image on the disk using R

Consider for both the situations: 1. Image will ...READ MORE

Apr 14, 2018 in Data Analytics by Sahiti
• 6,370 points
1,846 views
0 votes
1 answer

How to install an R package from source?

If you have your file located locally ...READ MORE

Apr 14, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
613 views
0 votes
1 answer

Concatenate 2 strings in R

You can use the paste() command: You can ...READ MORE

Apr 14, 2018 in Data Analytics by Sahiti
• 6,370 points
1,099 views
0 votes
1 answer

Any built-in function to find mode

You can try out the below code ...READ MORE

Apr 14, 2018 in Data Analytics by kappa3010
• 2,090 points
370 views
+1 vote
1 answer

How to convert a list of dataframes in to a single dataframe using R?

You can use the plyr function: data <- ...READ MORE

Apr 14, 2018 in Data Analytics by Sahiti
• 6,370 points
6,339 views
+1 vote
1 answer

How to convert dataframe columns from factors to characters?

To replace all the variables to character ...READ MORE

Apr 13, 2018 in Data Analytics by BHARANI
• 420 points
19,244 views
0 votes
1 answer

Rename a single column in dataframe using R

colnames(Samp)[2] <- "newname2" This sets the name of ...READ MORE

Apr 13, 2018 in Data Analytics by kappa3010
• 2,090 points
1,847 views
0 votes
1 answer

How to create an empty dataframe?

Initialize with empty vectors: data <- data.frame(Date=as.Date(character()), ...READ MORE

Apr 13, 2018 in Data Analytics by nirvana
• 3,130 points
1,173 views
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
2,324 views
0 votes
1 answer

Sample random rows in DataFrame in R

First we should have some data: df1<-data.frame(matrix(rnorm(20), nrow=10)) > ...READ MORE

Apr 13, 2018 in Data Analytics by DeepCoder786
• 1,720 points
7,855 views
0 votes
1 answer

.SD in data.table in R

.SD stands for "Subset of Data.table". The ...READ MORE

Apr 13, 2018 in Data Analytics by nirvana
• 3,130 points
6,668 views
0 votes
1 answer

Working of ggplot scale_continuous 'expand' argument

According to the document if you set limits manually, ...READ MORE

Apr 13, 2018 in Data Analytics by DataKing99
• 8,240 points
2,908 views
0 votes
1 answer

What is the difference between [] and [[]] notations to access the elements of a list or dataframe in R?

R provides 3 basic indexing operators. Refer ...READ MORE

Apr 12, 2018 in Data Analytics by kappa3010
• 2,090 points
2,680 views
0 votes
1 answer

How to find out the sum/mean for multiple variables per group in R?

You can use the reshape2 package for ...READ MORE

Apr 12, 2018 in Data Analytics by DataKing99
• 8,240 points
3,396 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

Apr 12, 2018 in Data Analytics by nirvana
• 3,130 points

edited Apr 12, 2018 by nirvana 21,846 views
0 votes
1 answer

How to merge data frames using joins?

You can use the merge function with ...READ MORE

Apr 12, 2018 in Data Analytics by kappa3010
• 2,090 points
653 views
0 votes
1 answer

How to group all columns exculding a single column?

You can either use group_by or group_by_at Using ...READ MORE

Apr 12, 2018 in Data Analytics by Sahiti
• 6,370 points
3,221 views
0 votes
1 answer

How to join a list of data frames using map()

You can use reduce set.seed(24) r1 <- map(c(5, 10, ...READ MORE

Apr 11, 2018 in Data Analytics by kappa3010
• 2,090 points
1,266 views
0 votes
1 answer

How to apply list to a function which give data frame as output

If you use  tidyverse, you can use ...READ MORE

Apr 11, 2018 in Data Analytics by Sahiti
• 6,370 points
469 views
0 votes
1 answer

How to extract specific columns from a DataFrame ?

Yes there are so many ways: df[,c(V2,V4)] and another ...READ MORE

Apr 11, 2018 in Data Analytics by DeepCoder786
• 1,720 points
8,371 views
0 votes
1 answer

How to drop data frame columns by name?

Easily you can do it: drops <- c("V2","V4") df1[ ...READ MORE

Apr 10, 2018 in Data Analytics by DeepCoder786
• 1,720 points
640 views
0 votes
1 answer

How to replace NA values in a dataframe with Zero's ?

It is simple and easy: df1<-as.data.frame(matrix(sample(c(NA, 1:10), 100, ...READ MORE

Apr 10, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
1,839 views
0 votes
1 answer

How to create excellent examples in R?

An excellent example must consist of the ...READ MORE

Apr 10, 2018 in Data Analytics by kappa3010
• 2,090 points

edited Apr 12, 2018 by kappa3010 507 views
0 votes
1 answer

R - Error: Duplicate identifiers for rows

You can try the below code as ...READ MORE

Apr 9, 2018 in Data Analytics by kappa3010
• 2,090 points
2,729 views
0 votes
1 answer

How to spilt a column of a data frame into multiple columns

it is easily achievable by using "stringr" ...READ MORE

Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,478 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,023 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by Gitika 913 views
0 votes
1 answer

How to apply loops to multiply across various columns in a dataframe?

I am assuming that your columns are ...READ MORE

Apr 6, 2018 in Data Analytics by kappa3010
• 2,090 points
6,401 views
0 votes
1 answer

How to use dplyr functions such as filter() inside nested data frames with map()

You can use map() call as follows:  map(full, ...READ MORE

Apr 6, 2018 in Data Analytics by Sahiti
• 6,370 points
4,286 views
0 votes
1 answer

Join list of data.frames using map() call

You can use Reduce set.seed(24) r1 <- map(c(5, 10, 15), ...READ MORE

Apr 6, 2018 in Data Analytics by Sahiti
• 6,370 points
798 views
0 votes
1 answer

How to join two tables (tibbles) by *list* columns in R

You can use the hash from digest ...READ MORE

Apr 6, 2018 in Data Analytics by kappa3010
• 2,090 points
1,418 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,631 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
2,020 views
0 votes
1 answer

How to achieve pivot like data using tidyverse library in R?

You need not spread twice, if you ...READ MORE

Apr 4, 2018 in Data Analytics by kappa3010
• 2,090 points
874 views
0 votes
1 answer

How can I use parallel so that it preserves the list of data frames

You can use pmap as follows: nc <- ...READ MORE

Apr 4, 2018 in Data Analytics by kappa3010
• 2,090 points
787 views
0 votes
1 answer

Removing unimportant variables before building Random Forest

Build the randomForest model on top of ...READ MORE

Apr 4, 2018 in Data Analytics by Bharani
• 4,660 points
1,929 views
0 votes
1 answer

AUC for 3-Class prediction in R

Use type='probs' inside predict() function, so that ...READ MORE

Apr 4, 2018 in Data Analytics by Bharani
• 4,660 points
1,171 views
0 votes
1 answer

Calculating accuracy of prediction of rpart model

Your first task would be to build ...READ MORE

Apr 4, 2018 in Data Analytics by Bharani
• 4,660 points
7,879 views