Last data update: 2014.03.03

R: Compactly Show STRucture of Rmpfr Number Object
str.mpfrR Documentation

Compactly Show STRucture of Rmpfr Number Object

Description

The str method for objects of class mpfr produces a bit more useful output than the default method str.default.

Usage

## S3 method for class 'mpfr'
str(object, nest.lev, give.head=TRUE,
    digits.d = 12, vec.len = NULL, drop0trailing=TRUE,
    width = getOption("width"), ...)

Arguments

object

an object of class mpfr.

nest.lev

for str(), typically only used when called by a higher level str().

give.head

logical indicating if the “header” should be printed.

digits.d

the number of digits to be used, will be passed formatMpfr() and hence NULL will use “as many as needed”, i.e. often too many. If this is a number, as per default, less digits will be used in case the precision (getPrec(object)) is smaller.

vec.len

the number of elements that will be shown. The default depends on the precision of object and width (since Rmpfr 0.6-0, it was 3 previously).

drop0trailing

logical, passed to formatMpfr() (with a different default here).

width

the (approximately) desired width of output, see options(width = .).

...

further arguments, passed to formatMpfr().

See Also

mpfrIs0 for many more utilities.

Examples

(x <- c(Const("pi", 64), mpfr(-2:2, 64)))
str(x)
str(list(pi = pi, x.mpfr = x))
str(x ^ 1000)
str(x ^ -1e4, digits=NULL) # full precision

uu <- Const("pi", 16)# unaccurate
str(uu) # not using default of 12 digits

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Rmpfr)
Loading required package: gmp

Attaching package: 'gmp'

The following objects are masked from 'package:base':

    %*%, apply, crossprod, matrix, tcrossprod

C code of R package 'Rmpfr': GMP using 64 bits per limb


Attaching package: 'Rmpfr'

The following objects are masked from 'package:stats':

    dbinom, dnorm, dpois, pnorm

The following objects are masked from 'package:base':

    cbind, pmax, pmin, rbind

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Rmpfr/str.mpfr.Rd_%03d_medium.png", width=480, height=480)
> ### Name: str.mpfr
> ### Title: Compactly Show STRucture of Rmpfr Number Object
> ### Aliases: str.mpfr
> ### Keywords: utilities
> 
> ### ** Examples
> 
> (x <- c(Const("pi", 64), mpfr(-2:2, 64)))
6 'mpfr' numbers of precision  64   bits 
[1] 3.14159265358979323851                     -2                     -1
[4]                      0                      1                      2
> str(x)
Class 'mpfr' [package "Rmpfr"] of length 6 and precision 64
 3.14159265359 -2 -1 0 1 2 
> str(list(pi = pi, x.mpfr = x))
List of 2
 $ pi    : num 3.14
 $ x.mpfr:Class 'mpfr' [package "Rmpfr"] of length 6 and precision 64
 .. 3.14 -2 -1 0 ...
> str(x ^ 1000)
Class 'mpfr' [package "Rmpfr"] of length 6 and precision 64
 1.41212354452e497 1.07150860719e301 1 0 1 1.07150860719e301 
> str(x ^ -1e4, digits=NULL) # full precision
Class 'mpfr' [package "Rmpfr"] of length 6 and precision 64
 3.17156092605667754228e-4972 5.012372749206452009e-3011 1 Inf 1 ...
> 
> uu <- Const("pi", 16)# unaccurate
> str(uu) # not using default of 12 digits
Class 'mpfr' [package "Rmpfr"] of length 1 and precision 16
 3.1416 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>