How calculate total in a table function

I am doing frequency using the table function and wanted to know if I can total in the code?
How can I code it to Calculate total in the table function?

a_vec <- c(1:5,5:3)

Thank you! How about if I want to calculate the total by rows and columns. How can I do in the table function?

please give an example

Here is an example. I created this frequency using the table function. And I want to add total for each rows and columns and sum total in the output.

        A.            B.               Total
        1268       26895            ?
        467          462                 ?

Total ? ? ?

d <- data.frame(A = c(1268,467), 
                B = c(26895,462),
                Total = c(NA,NA))

d$Total = rowSums(d[1:2])
#>      A     B Total
#> 1 1268 26895 28163
#> 2  467   462   929

Created on 2023-02-25 with reprex v2.0.2

Screenshot 2023-02-25 at 10.54.19 PM

d$Total = rowSums(d, na.rm = TRUE)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.