form: Format a String with Perl6::Form

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/form.R

Description

A wrapper around the Perl function form provided by Damian Conway's Perl6::Form module.

Usage

1
form(..., cat = TRUE, perl = "perl", form.options)

Arguments

...

character and numeric vectors. See Examples.

cat

logical: should result be printed?

perl

name and path of the perl programme

form.options

optional: a list of named options; see Examples.

Details

A simple wrapper, implemented via a call to system2.

Value

character

Author(s)

Enrico Schumann

References

See the extensive help of the Perl function: http://search.cpan.org/~dconway/Perl6-Form/lib/Perl6/Form.pm

See Also

system2

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
nums <- c(2.1711119999, 1000.1, 0.999)
form("* {]]]]]].[} *", nums)

##  ... results in
##  *       2.17 *
##  *    1000.1  *
##  *       1.00 * 


## use decimal separator as specified by locale
form("{]]]]]],[}", nums,
     form.options = list(locale = 1))



Names <- c("Al", "Bob", "Carl")
Values <- c(0.257, 100.1, 98)

form("+--------+--------+",
     "|     Id |  Value |",
     "+========+========+",
     "| {]][[} | {]].[} |",
          Names,    Values,
     "+--------+--------+")

##  ... results in
##  +--------+--------+
##  |     Id |  Value |
##  +========+========+
##  |   Al   |   0.26 |
##  |  Bob   | 100.1  |
##  |  Carl  |  98.0  |
##  +--------+--------+ 

enricoschumann/Perl6.Form documentation built on May 13, 2017, 6:08 p.m.