Scientific Representation

summary(model1)gives the results with scientific representation meaning that the results look like 1.796e-01 . I would like to have them 0.1796. How can change it?

Hi @korkut_keles
Try this

format(summary(model1), scientific=FALSE)
1 Like

but it does not produce a table, it gives the coefficients as a list.

in general how numeric printing to the console with regard to the choice of whether or not to use Scientific Notation, is affected by the scipen option. However; if you want to make display tables, like for a report in html; you would more explicitly use appropriate formatters depending on the chosen table reporting packages;
here is an example that uses gt

# this is the example linear regression in R's help 
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)

# demonstrating how scipen affects what prints to console
options(scipen = 99999);summary(lm.D9);
options(scipen = 1);summary(lm.D9);

# using gt for making a table fit for reports

options(scipen = 99999);gt(tidy(lm.D9));
options(scipen = 1);gt(tidy(lm.D9));

# more direct control example # fmt_number has other options
# and there are other fmt_ functions to choose from
gt(tidy(lm.D9)) |> gt::fmt_number(columns = where(is.numeric))

This topic was automatically closed 7 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.