enter image description here I have a dataframe that has several rows with the same ID and columns 1 to 1273 (please see image). I would like to merge all the rows with the same ID.
I tried this R code (attached image - I can't seem to add my code in text) enter image description here :
This did not exactly work for me because I was expecting to see the attached image enter image description here . Could I please get some assistance with this, I would greatly appreciate it.
This should work for you. df %>% group_by(sample)%>% summarise(across(starts_with("a"), ~sum(., na.rm = T)))
taken from this post: R: Combine rows with same ID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.