Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
3 votes
3 answers
73 views

Merging duplicated rows and create new column based on which rows were duplicated

Let's say I have the following: df=read.table(text="ID ColB ColC ColD 1 A S1 X,Y,Z 2 A S2 A,B,C 3 B S3 A,B,C 4 B S4 X 5 C S6 X 6 C S8 X ", header=TRUE) I want to merge duplicated rows based ...
Gabriel G.'s user avatar
0 votes
2 answers
50 views

I'm trying to create a new column from an existing column and then delete any duplicate IDS

I'm trying to create a new column from an existing column and then delete any duplicate IDS. My df looks like this: This is what my dataframe currently looks like, it's three columns of unique ID, ...
Diana 's user avatar
0 votes
1 answer
88 views

r retain non zero rows in case of duplicates

I have a dataset with duplicate rows if we group by two columns ID Group Value 1 z1 0 1 z1 0.81 2 z2 2.89 2 z2 1.53 3 z1 ...
Ahir Bhairav Orai's user avatar
0 votes
1 answer
42 views

r retain duplicates after group by not min value

I have a dataset like this. ID Group Value Col3 1 z1 1.29 1 1 z1 0.81 1 2 z2 2.89 1 2 z2 1.53 2 3 z1 0.13 ...
Ahir Bhairav Orai's user avatar
0 votes
1 answer
502 views

Sum values of a single column in duplicated rows in R [duplicate]

I have the following data in R. I need to aggregate the Num values when other values of two (or more) rows are the same. I know the answer for data with two columns but how should I have it for more ...
Ester Silva's user avatar
1 vote
1 answer
847 views

Sum duplicate rows that are grouped and combine their IDs in R

I have seal data that is grouped by columns: ID, dive number, and dive phase. I summarize this data over 20 second intervals from my original dataframe. When I do this, it creates duplicate 20 second ...
Shawn68's user avatar
  • 19
1 vote
5 answers
488 views

How to remove duplicate ID values but keep the row with the highest age

I have the following dataset where I have replicates of the same ID entry (example: 20103 is repeated twice): head(Data) ## X ID DOB sector meters Oct Res_FROM Res_TO Exp_FROM ...
barnsm2's user avatar
  • 195
0 votes
2 answers
590 views

Collapsing rows with consecutive ranges in two separate columns

I would very much appreciate your help on this one. I'm trying to condense a data frame of 200,000+ rows, where the integer of one row in column "start" is the exact to the next consecutive ...
OncoComp's user avatar
1 vote
2 answers
231 views

Consolidate duplicate rows into one by applying a formula

In R I want to consolidate rows where data points with the same x,y coordinates can be merged with a formula to give a single row representing the combined area values. (Multi-stemmed trees but the ...
David Cracknell's user avatar
0 votes
1 answer
1k views

R: Collapse partial duplicate rows into one row by ID but with different conditions per column

I'm trying to merge or collapse rows which are partial duplicates based on ID and with varying conditions based on the column. I'd like to end up with a single row per ID in a new dataframe. This is ...
Selena's user avatar
  • 1
1 vote
2 answers
232 views

aggregate and removes duplicates for some rows

I have a dataset like df <- data.frame(id = c("a","a","b","b","c","d","e","f"), val = c(1,2,3,4,5,6,...
Massimiliano Sfregola's user avatar
0 votes
1 answer
36 views

Removing duplicate rows from one column without losing data from another column

I apologize if this has already been asked, but the solutions I came across didn't seem to work for me. I have a data set that was initially multiple excel sheets containing different variables for ...
jmar1212's user avatar
0 votes
2 answers
70 views

Collapsing columns sharing unique value (s) in R

How can I collapse columns of rows, giving that they share unique values? I have a data frame like this: Group Status Temperature Ref A Moving 1 A Cold ...
kaka01's user avatar
  • 65
2 votes
2 answers
3k views

How to retain one of the duplicated rows randomly in r (not the first duplicated row)

I have a large dataset with many duplicated rows. I want to remove duplicated rows and retain only unique rows. But I don't want to retain the first duplicated row, which is the case in dplyr::...
Sisay 's user avatar
  • 43
1 vote
1 answer
42 views

Average only duplicated rows and replacing value in a defined column

I have a dataframe D: surname name salary Red A 1000 Green B 900 Green A 1100 Blue C 1000 Blue B 1000 Blue F 800 Violet F ...
Valdarn8's user avatar

15 30 50 per page