Function to round the numeric variables in a data frame.

dfround(x, digits)

Arguments

x

a data frame.

digits

either a single integer or a numeric vector of the same length as there are columns in x.

Details

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.

Value

Returns the data frame with variables rounded as specified.

Examples

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))
#>             estimate          se       zval        pval        ci.lb        ci.ub
#> intrcpt -3.545505079 29.09587983 -0.1218559 0.903013130 -60.57238164 53.481371479
#> ablat   -0.028011275  0.01023404 -2.7370689 0.006198931  -0.04806963 -0.007952924
#> year     0.001907557  0.01468382  0.1299088 0.896638598  -0.02687219  0.030687307
dfround(coef(summary(res)), digits=c(2,3,2,3,2,2))
#>         estimate     se  zval  pval  ci.lb ci.ub
#> intrcpt    -3.55 29.096 -0.12 0.903 -60.57 53.48
#> ablat      -0.03  0.010 -2.74 0.006  -0.05 -0.01
#> year        0.00  0.015  0.13 0.897  -0.03  0.03