dfround | R Documentation |
Function to round the numeric variables in a data frame.
dfround(x, digits, drop0=TRUE)
x |
a data frame. |
digits |
either a single integer or a numeric vector of the same length as there are columns in |
drop0 |
logical (or a vector thereof) indicating if trailing zeros after the decimal mark should be removed (the default is |
A simple convenience function to round the numeric variables in a data frame, possibly to different numbers of digits. Hence, digits
can either be a single integer (which will then be used to round all numeric variables to the specified number of digits) or a numeric vector (of the same length as there are columns in x
) to specify the number of digits to which each variable should be rounded.
Non-numeric variables are skipped. If digits
is a vector, some arbitrary value (or NA
) can be specified for those variables.
Note: When drop0=FALSE
, then formatC
is used to format the numbers, which turns them into character variables.
Returns the data frame with variables rounded as specified.
Wolfgang Viechtbauer wvb@metafor-project.org https://www.metafor-project.org
dat <- dat.bcg
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
res <- rma(yi, vi, mods = ~ ablat + year, data=dat)
coef(summary(res))
dfround(coef(summary(res)), digits=c(2,3,2,3,2,2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.