For just console output read @EliBerkow's link in the comment to your question. For table outputs or to use in a function you may use formatC()
.
Example
(output <- summary(glm(I(Sepal.Length > 5.7) ~ Sepal.Width + Species, iris,
family=binomial()))$coefficients)
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -15.846295 3.893382 -4.070059 4.700128e-05
# Sepal.Width 3.274112 0.970872 3.372342 7.453193e-04
# Speciesversicolor 7.149531 1.533740 4.661501 3.139108e-06
# Speciesvirginica 9.283911 1.630188 5.694992 1.233776e-08
All with four digits:
as.data.frame(apply(output, 2, formatC, format="f", digits=4))
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -15.8463 3.8934 -4.0701 0.0000
# Sepal.Width 3.2741 0.9709 3.3723 0.0007
# Speciesversicolor 7.1495 1.5337 4.6615 0.0000
# Speciesvirginica 9.2839 1.6302 5.6950 0.0000
Different number of digits:
setNames(data.frame(output[,-4], formatC(output[,4], format="f", digits=4)), colnames(output))
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -15.846295 3.893382 -4.070059 0.0000
# Sepal.Width 3.274112 0.970872 3.372342 0.0007
# Speciesversicolor 7.149531 1.533740 4.661501 0.0000
# Speciesvirginica 9.283911 1.630188 5.694992 0.0000