lprintf: String formatting given an environment

Description Usage Arguments Value Author(s) See Also Examples

Description

String formatting given an environment

Usage

1
lprintf(x, envir = sys.frame(sys.parent(1)))

Arguments

x

character, a string to format.

envir

the environment to use.

Value

character

Author(s)

Xiaobei Zhao

See Also

sprintf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
a="fox";b="dog";
x <- 'The quick brown %(a)s jumps over the lazy %(b)s?
Or the quick brown %(b)s jumps over the lazy %(a)s?'

## format given the global environment
lprintf(x)
## [1] "The quick brown fox jumps over the lazy dog?
## Or the quick brown dog jumps over the lazy fox?"

## format given a local environment
myenv <- new.env()
local(
  {a="coyote";b="dog";},
  envir=myenv
)
lprintf(x,myenv)
## [1] "The quick brown coyote jumps over the lazy dog?
## Or the quick brown dog jumps over the lazy coyote?"

Example output

Attaching package: 'Xmisc'

The following object is masked from 'package:base':

    dir.exists

[1] "The quick brown fox jumps over the lazy dog?\nOr the quick brown dog jumps over the lazy fox?"
[1] "The quick brown coyote jumps over the lazy dog?\nOr the quick brown dog jumps over the lazy coyote?"

Xmisc documentation built on May 2, 2019, 8:23 a.m.