By using dpylr package sum of multiple columns

0 votes

Using mtcars dataset

image

I want to sum the columns but not using other methods because other function does not works on SQL

reduce,rowwise, rowSums doesn't work for sql tables

I want some like this

image

Apr 5, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
98 views

1 answer to this question.

0 votes

Basically here we are making an equation and evaluating it.

library("dplyr")

library(stringr)

#fetching varaible names and forming an equation

equation_<- paste0(collapse = "+",str_subset(colnames(mtcars),"[a-z]"))

#using mutate function parsing and evaluating the equation to the result

mtcars %>% mutate(Sum_Col=eval(parse(text=equation_)))
answered Apr 5, 2018 by DeepCoder786
• 1,700 points

Related Questions In Data Analytics

0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 5 in Data Analytics by anonymous
2,856 views
0 votes
1 answer

Using dplyr package to summarise multiple columns - R

'dplyr' package provides 'summarise_all()' function to apply ...READ MORE

answered Jun 6, 2018 in Data Analytics by Bharani
• 4,550 points
334 views
0 votes
1 answer

Using "dplyr" to summarise multiple columns

You can use the "sumamrise_all()" function for ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
229 views
0 votes
1 answer

Trying to find frequent itemsets of a data set using arules package

Try replacing ID <- c("A123","A123","A123","A123","B456","B456","B456") item <- c("bread", "butter", "milk", ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,040 points
39 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

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

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
76 views
0 votes
1 answer

With the help of tidyverse: how to rename a column to a variable name

With the help of Dplyr: rename function ...READ MORE

answered Apr 3, 2018 in Data Analytics by DeepCoder786
• 1,700 points

edited Apr 3, 2018 by DeepCoder786 41 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

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
118 views
0 votes
1 answer

How to create a list of Data frames?

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

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
70 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

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
87 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

answered Apr 10, 2018 in Data Analytics by DeepCoder786
• 1,700 points
29 views