I have a data frame with multiple columns and I want to add a top row with sum of all the columns.
mydf
id name val1 val2 val3 val4
1 abc 1 3 2.2 3.1
2 def 2 3 3.2 1.3
This is what I am trying
tot<-mydf %>%
summarize_if(is.numeric, sum, na.rm=TRUE)
But this would only show sum for val1 and val2.
Desired output
id name val1 val2 val3 val4
Total 3 6 5.4 4.4
1 abc 1 3 2.2 3.1
2 def 2 3 3.2 1.3