Format2: Render numbers

Description Usage Arguments Value Examples

Description

Formatieren von Zahlen nach APA-Style.

rndr2 ist die interne default-Methode um statistische Kennzahlen wie t, p, oder r zu Formatieren

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Format2(x, ...)

ergaenze_vector(x, n_cols = NULL)

drop_0_leading(x, OutDec = getOption("OutDec"))

make_format(x, digits, format, drop0trailing, drop0leading, decimal.mark,
  na.strings = "NA", na.symbol = "")

## S3 method for class 'matrix'
Format2(x, digits = 2, lead.zero = TRUE,
  drop0leading = !lead.zero, format = "f", ...)

## S3 method for class 'tbl_df'
Format2(x, ...)

## S3 method for class 'data.frame'
Format2(x, digits = 2, lead.zero = TRUE,
  drop0leading = !lead.zero, format = "f", ...)

## S3 method for class 'list'
Format2(x, digits = NULL, lead.zero = TRUE,
  drop0leading = !lead.zero, format = "f", ...)

## Default S3 method:
Format2(x, digits = 2, lead.zero = TRUE,
  scientific = FALSE, nsmall = ifelse(is.null(digits), 0L, digits),
  drop0leading = !lead.zero, drop0trailing = FALSE, format = "f",
  decimal.mark = getOption("OutDec"), ...)

rndr2(...)

## S3 method for class 'matrix'
rndr2(x, ...)

## S3 method for class 'data.frame'
rndr2(x, ...)

## Default S3 method:
rndr2(x, digits = 2, format = "f", drop0leading = FALSE,
  drop0trailing = FALSE, decimal.mark = getOption("OutDec"),
  include.leading = FALSE, include.trailing = FALSE,
  include.bracket = FALSE, symbol.bracket = c("(", ")"),
  symbol.leading = " # ", symbol.trailing = " # ", ...)

Arguments

x

Objekt kann Vector data.frame oder list sein

...

an FormatC

n_cols

anzahl an Elementen (intern in ergaenze_vector())

OutDec

Detzimal-Trenzeichen wird bei rndr_ verwendet und ueber Optionen gesteuert

digits

Nachkommastellen als vektor oder liste

format

format an formatC()

drop0trailing

Nullen am Ende an formatC()

decimal.mark

Kommatrennzeichen an formatC()

na.strings, na.symbol

in der internen Funktion make_format genutzt und kann nur über Optionen geändert werden (noch nicht implementiert)

lead.zero, drop0leading

Null am Anfang an formatC()

scientific, nsmall

format an formatC()

include.leading, symbol.leading

Vorangestelltes Symbol

include.trailing, symbol.trailing

Nachgestelltes Symbol

include.bracket, symbol.bracket

Klammern

Value

Gleiches objekt wie der Input aber mit Character.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
stp25rndr:::ergaenze_vector(c(1,2,4), 6)


stp25rndr:::drop_0_leading(0.26589)


stp25rndr:::make_format(c(12.5, NA, 32.1459),
                          2, "f", FALSE, FALSE, ".")



 x<- rnorm(10)
df <- data.frame(Item=c("a", "b", "c"),
                 x=x[1:3],
                 x2=c(1.2,2.3,.3),
                 beta=  c(.22,.13, NA),
                 x3=c(.42,.03,.003),
                 p.value=c(0.0002456,0.0398,.256))

mx1<- as.matrix(df[,-1])
mx2<-matrix(rnorm(10), ncol=2)
#- matrix ---------------------------
res <- Format2(mx1, digits=2)
cat("\n in: matrix out:", class(res)," \n")
res
x<-mx2[,1]
res <- Format2(x, digits=c(1:5), drop0trailing = TRUE)
cat("\n in: ", class(x)," out:", class(res)," \n")
res
Format2(x, c(1:3))


#- tbl_df/data.frame ----------------------
#Format2(tribble::tbl_df(df), digits=3)


 x<- rnorm(10)
df <- data.frame(Item=c("a", "b", "c"),
                 x=x[1:3],
                 x2=c(1.2,2.3,.3),
                 beta=  c(.22,.13, NA),
                 x3=c(.42,.03,.003),
                 p.value=c(0.0002456,0.0398,.256))
#- data.frame ----------------------
res <- Format2(df[,-1], digits=2, FALSE)
cat("\n in: data.drame out:", class(res)," \n")
res
Format2(df, digits=3)


lx<- list(a=1:5, b=rnorm(10))

#- list --------------------------
res <- Format2(lx, 2, FALSE)
cat("\n in: list out:", class(res)," \n")
res

 x<- rnorm(10)
 
 #- vector -------------------------
 res<-Format2(x, digits=2, FALSE)
 cat("\n in: numeric out:", class(res)," \n")
 res
 Format2(as.character(x), digits=3)
 Format2(factor(x), digits=3)

stp4/stp25rndr documentation built on May 31, 2019, 10:50 p.m.