How to modify column values using the same column without duplicating column?

0 votes
How to modify column values using the same column without duplicating column?

I need to perform some calculations from existing column values and modify the same column.How to acheive this?

My dataset conatins too many rows, so duplicating or creating a new column is not preferred.
Aug 29 in Data Analytics by piyush
22 views

1 answer to this question.

0 votes

Hi,

Use mutate(). returns selected columns after modifying the existing values with new calculated values in the column. if you want to return only updated column values use transmute().

mutate() adds new variables and preserves existing ones. transmute() adds new variables and drops existing ones. Both functions preserve the number of rows of the input. New variables overwrite existing variables of the same name.

Ex: 

mtcars %>% mutate(cyl = cyl/2)
mtcars %>% transmute(cyl= cyl/2)
answered Aug 30 by anonymous
• 31,840 points

Related Questions In Data Analytics

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,720 points

edited Apr 3, 2018 by DeepCoder786 48 views
0 votes
1 answer

How can I print string and variable contents on the same line using R?

There are two options for doing so.  You ...READ MORE

answered May 9, 2018 in Data Analytics by zombie
• 3,690 points
34 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,690 points
195 views
0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by Anmol
• 3,620 points

edited Aug 28, 2018 by Vardhan 60 views
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
3,597 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

answered Apr 12, 2018 in Data Analytics by darklord
• 6,170 points
91 views
0 votes
0 answers

dplyr R - Pipelining

Hi, can you tell how pipelining works ...READ MORE

Jul 12 in Data Analytics by riya
30 views
0 votes
1 answer

Sort a field based on another field in R

Hi.. Just for sorting, you can use arrange ...READ MORE

answered Aug 29 in Data Analytics by Gups_1985
28 views
0 votes
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
131 views
0 votes
2 answers