Summing numerical values in individual columns

Hi @Adam52: In principle, the specific task you mention has a straightforward solution, but as usual, the devil is often in the details, so it's best if you can post a sample of your actual data or something that mimics it as closely as possible.

The sample table you posted is a good start, but isn't easily copied and pasted by folks who would like to help, and doesn't contain details about that structure of the table. It would be helpful if instead you could paste a sample of your data like this:

```
<--- paste output of dput(my_table %>%  select(1:10) %>% head(20)) here, 
       (including ```s)
```

where my_table is either a toy table as you created, or your actual table. (See FAQ: How to do a minimal reproducible example ( reprex ) for beginners for a guide on best practices for sharing data and code here.)

Here's code that may accomplish the narrow task you described, but may not be the ideal solution in your specific context, which could recommend a restructuring of your actual data:

my_table %>% 
  group_by(CellType) %>% 
  summarise_if(is.numeric, sum)

I hope this helps.

2 Likes