So basically I have a sample dataframe that kinda looks like this:
Community Pop_Total Median_Age Under_5 5-9 10-14 15-19 20-24
Akutan city NA NA NA NA NA NA 71
Alcan Border NA NA 2 NA NA NA NA
Alcan Border NA NA NA NA NA 2 NA
Alcan Border NA NA NA NA 5 NA NA
Ambler City 224 NA NA NA NA NA NA
Ambler City NA NA NA 17 NA NA NA
But with gene names rather than numbers.
Is there a simple way to combine multiple rows based on multiple column data? I've seen a few scripts that say you can combine one duplicate variable in a column based on one or two data columns but I need to do it more large scale (I have ~400 rows with duplicates and ~30 columns (and each column has a large name). Ideally it would look like:
Community Pop_Total Median_Age Under_5 5-9 10-14 15-19 20-24
Akutan city NA NA NA NA NA NA 71
Alcan Border NA NA 2 NA 5 2 NA
Ambler City 224 NA NA 17 NA NA NA
AGAIN with gene names rather than numbers1
The following is my code:
df <- Good1_Poor3 %>% spread(key = Gene, value = consequences)
df <- df %>%
group_by(sample_id) %>%
summarise_if(
is.character,
sum,
na.rm = TRUE
)
r
genomics
Hello ngcatung0!
Questions similar to yours can already be found at:
We have closed your question to allow us to keep similar content in the same thread.
If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.
Cheers!
ngcatung0 why did you create this post? The post you created earlier already had responses. Please do not do that, it is bad practice and disrespectful towards the users who already invested into the first thread.
Kevin Blighe would you mind moving your very good answer to the other thread so we can keep things concentrated?
Of course, Kind Sir.
Thanks respected Sir Kevin :)