PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 11, 2022

[FIXED] How to change the decimals in my lsmeans output

 August 11, 2022     decimal, r     No comments   

Issue

Forgive my lack of R knowledge. I am running some statistics, however I have some problems with the number of decimals in the output. The table I use is simple, inlcuding 2 colums of 'text' and two 'numeric'. The table shows 5 digits (3 decimals). However when working with this table R studio only gives 1 decimal. Not only in my lsmeans results but already in my head(X).

I already tried the following (where X is data):

>format(X, digits=5)

>format(X, decimals=3)

>print(lsmeans,decimals=3)

>options(digits = 5)

However the columns N and Dm are still rounded to 1 decimal.

> N   92.4   92.4  93.7 .....         
> Dm  44.8 51.2 49.0 ....

> lsmean 92.7  93.3 92.2

I would like to see the columns N and Dm with 3 decimals like (I see them at the table when used view(x)), and likewise the results of N of the lsmean.

Example data:

X <- structure(list(Diet = structure(c(1L, 1L, 1L, 1L, 1L, 1L), 
                                     .Label = c("1", 
                                                "2", "3", "4"), 
                                     class = c("ordered", "factor")), 
                    Room = structure(c(1L, 
                                       1L, 1L, 1L, 1L, 2L), 
                                     .Label = c("1", "2"), class = c("ordered", 
                                                                     "factor")), 
                    Ndigestibility = c(92.3961026914675, 91.3131265857907, 
                                       93.7094576131358, 93.1557358031795, 
                                       91.6853770290382, 93.2698082975574), 
                    Dmdigestibility = c(44.7692224966736, 51.2173172537712, 
                                        49.0100980168149, 45.6289084300095, 
                                        45.9036710781654, 45.3144774487225)), 
               row.names = c(NA, 
                             -6L), class = c("tbl_df", "tbl", "data.frame"))

X
#   Diet Room Ndigestibility Dmdigestibility
# 1    1    1       92.39610        44.76922
# 2    1    1       91.31313        51.21732
# 3    1    1       93.70946        49.01010
# 4    1    1       93.15574        45.62891
# 5    1    1       91.68538        45.90367
# 6    1    2       93.26981        45.31448

Solution

You can do

emm_options(opt.digits = FALSE)

This will disable the feature in the emmeans package (for which lsmeans is a front end) whereby results are displayed in reasonable precision relative to their standard errors.



Answered By - Russ Lenth
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing