Skip to content

Instantly share code, notes, and snippets.

@fmichonneau
Created June 17, 2015 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmichonneau/92450a4604fb201ebb7c to your computer and use it in GitHub Desktop.
Save fmichonneau/92450a4604fb201ebb7c to your computer and use it in GitHub Desktop.
summary row
tab <- data.frame(a = letters[1:4], b = 1:4, c = letters[5:8], d = 5:8,
stringsAsFactors = FALSE)
last_row <- apply(tab, 2, function(x) {
res <- as.numeric(x)
if (any(is.na(res)))
""
else sum(res)
})
tab <- rbind(tab, last_row)
knitr::kable(tab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment