Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 回归结果:默认显示格式_R_Options_Lm - Fatal编程技术网

R 回归结果:默认显示格式

R 回归结果:默认显示格式,r,options,lm,R,Options,Lm,我使用lm函数在R中运行回归,无法以简单格式显示结果。我需要打印一个p值向量: > summary(lm)$coef[,4] (Intercept) lun d1un 1.433706e-01 4.673723e-158 6.629044e-04 我如何超越科学记数法并获得合理的精度?我尝试了optionsscipen=1000,但它显示了无数行数字,不知何故optionsdigits=7在这里不起作用 我知道我可以使用诸如格式和spri

我使用lm函数在R中运行回归,无法以简单格式显示结果。我需要打印一个p值向量:

> summary(lm)$coef[,4]
  (Intercept)           lun          d1un 
 1.433706e-01 4.673723e-158  6.629044e-04 
我如何超越科学记数法并获得合理的精度?我尝试了optionsscipen=1000,但它显示了无数行数字,不知何故optionsdigits=7在这里不起作用


我知道我可以使用诸如格式和sprint之类的东西,但我想为所有数字输出设置默认显示规则,例如不超过6位小数。

我认为这不可能,因为在整个R中的常规显示?选项中有关于数字的说明:

 ‘digits’: controls the number of digits to print when printing
      numeric values.  It is a suggestion only.  Valid values are
      1...22 with default 7.  See the note in ‘print.default’ about
      values greater than 15.
关键的短语是这只是一个建议

接下来,请注意,打印内容首先由应用的打印方法控制,这在交互使用期间是隐藏的,因为R自动打印。有关详细信息,请参见基本方法的“打印”和“打印默认值”。From?print.default我们注意到

在详细信息部分,我们有:

   The same number of decimal places is used throughout a vector.
   This means that ‘digits’ specifies the minimum number of
   significant digits to be used, and that at least one entry will be
   encoded with that minimum number.  However, if all the encoded
   elements then have trailing zeroes, the number of decimal places
   is reduced until at least one element has a non-zero final digit.
   Decimal points are only included if at least one decimal place is
   selected.
数字的默认值为NULL,这表示使用了getOptiondigits,但正如我们已经指出的,这只是一个指南


似乎没有一种方法可以配置R来做您想做的事情,也没有全局性地执行它。您需要重写print.default或您需要使用的所有打印方法,并使用这些版本,而不是标准版本。现在使用名称空间不容易。

您能给出预期的输出吗?是否要将lun的coef打印为0.000000?是的,除非明确指定其他精度,否则我希望为0.000000。
   The same number of decimal places is used throughout a vector.
   This means that ‘digits’ specifies the minimum number of
   significant digits to be used, and that at least one entry will be
   encoded with that minimum number.  However, if all the encoded
   elements then have trailing zeroes, the number of decimal places
   is reduced until at least one element has a non-zero final digit.
   Decimal points are only included if at least one decimal place is
   selected.