在R中显示变量的确切值 [英] Display exact value of a variable in R

查看:381
本文介绍了在R中显示变量的确切值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

> x <- 1.00042589212565
> x
[1] 1.000426

如果我想打印x的确切值,我该怎么做?

If I wanted to print the exact value of x, how would I do it?

抱歉,这是一个愚蠢的问题.我尝试使用Google搜索来搜索"R",精确"或取整",但我所获得的只是有关如何取整的文章.

Sorry if this is a dumb question. I tried Googling for "R" and "exact" or "round" but all I get are articles about how to round.

提前谢谢!

推荐答案

所有会话期间的全局解决方案

Globally solution during all the session

options(digits=16)
> x
[1] 1.00042589212565

或仅针对x:

sprintf("%.16f", x)
[1] "1.0004258921256499"

这篇关于在R中显示变量的确切值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆