vector2String: Convert a vector into a comma-separated string

Description Usage Arguments Value See Also Examples

View source: R/Vector2String.R

Description

A simple utility function that transforms any vector into a single character string, where the former vector elements are separated by commas. This is can be useful, in some circumstances, for feeding a series of constant numeric values to phasePortrait (see examples). For most applications we recommend, however, to use phasePortrait's parameter moreArgs instead.

Usage

1

Arguments

vec

The (usually real or complex valued) vector to be converted.

Value

A string, where the former vector elements are separated by commas, enclosed between "c(" and ")".

See Also

Other helpers: xlimFromYlim(), ylimFromXlim()

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
# Make a vector of 77 complex random numbers inside the unit circle
n <- 77
a <- complex(n, modulus = runif(n), argument = 2*pi*runif(n))
a <- vector2String(a)
print(a)


# Use this for portraying a Blaschke product

# x11(width = 9.45, height = 6.30) # Screen device commented out
                                   # due to CRAN test requirements.
                                   # Use it when trying this example
op <- par(mar = c(1, 1, 1, 1), bg = "black")
n <- 77
a <- complex(n, modulus = runif(n), argument = 2*pi*runif(n))
a <- vector2String(a)
FUN <- paste("vapply(z, function(z, a){
                    return(prod(abs(a)/a * (a-z)/(1-Conj(a)*z)))
                   }, a =", a,
             ", FUN.VALUE = complex(1))", sep = "")
phasePortrait(FUN, pType = "p", axes = FALSE,
              xlim = c(-3, 3), ylim = c(-2.0, 2.0),
              nCores = 2) # Max. two cores allowed on CRAN
                          # not a limit for your own use
par(op)
  

viscomplexr documentation built on Sept. 18, 2021, 5:06 p.m.