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, 2019 in Data Analytics by piyush
416 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, 2019 by anonymous
• 32,490 points

Related Questions In Data Analytics

0 votes
1 answer
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 104 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,750 points
103 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,720 points
1,014 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, 2019 in Data Analytics by anonymous
7,585 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 Sahiti
• 6,320 points
1,049 views
+1 vote
0 answers

dplyr R - Pipelining

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

Jul 12, 2019 in Data Analytics by riya
68 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, 2019 in Data Analytics by Gups_1985
110 views
+1 vote
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, 2019 in Data Analytics by anonymous
• 32,490 points
295 views
0 votes
2 answers

How to change the value of a variable using R programming in a data frame?

You are getting this error since the ...READ MORE

answered Aug 16, 2019 in Data Analytics by anonymous
• 32,490 points
12,756 views