bc_strrep

Broadcasted strrep

Description

The bc_strrep() method is a broadcasted form of strrep.

Usage

bc_strrep(x, y, ...)

## S4 method for signature 'ANY'
bc_strrep(x, y)

Arguments

x vector/array of type character.
y vector/array of type integer.
… further arguments passed to or from methods.

Value

A character array as a result of the broadcasted repetition operation.

Examples

library("broadcast")


x <- array(sample(month.abb), c(10, 2))
y <- array(sample(1:10), c(10, 2, 3))

print(x)
#>       [,1]  [,2] 
#>  [1,] "Feb" "Nov"
#>  [2,] "Dec" "Jun"
#>  [3,] "Jan" "Feb"
#>  [4,] "Aug" "Dec"
#>  [5,] "Apr" "Jan"
#>  [6,] "Oct" "Aug"
#>  [7,] "Mar" "Apr"
#>  [8,] "Sep" "Oct"
#>  [9,] "May" "Mar"
#> [10,] "Jul" "Sep"
print(y)
#> , , 1
#> 
#>       [,1] [,2]
#>  [1,]    2    2
#>  [2,]    6    6
#>  [3,]   10   10
#>  [4,]    7    7
#>  [5,]    1    1
#>  [6,]    5    5
#>  [7,]    3    3
#>  [8,]    9    9
#>  [9,]    8    8
#> [10,]    4    4
#> 
#> , , 2
#> 
#>       [,1] [,2]
#>  [1,]    2    2
#>  [2,]    6    6
#>  [3,]   10   10
#>  [4,]    7    7
#>  [5,]    1    1
#>  [6,]    5    5
#>  [7,]    3    3
#>  [8,]    9    9
#>  [9,]    8    8
#> [10,]    4    4
#> 
#> , , 3
#> 
#>       [,1] [,2]
#>  [1,]    2    2
#>  [2,]    6    6
#>  [3,]   10   10
#>  [4,]    7    7
#>  [5,]    1    1
#>  [6,]    5    5
#>  [7,]    3    3
#>  [8,]    9    9
#>  [9,]    8    8
#> [10,]    4    4

bc_strrep(x, y)
#> , , 1
#> 
#>       [,1]                             [,2]                            
#>  [1,] "FebFeb"                         "NovNov"                        
#>  [2,] "DecDecDecDecDecDec"             "JunJunJunJunJunJun"            
#>  [3,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"
#>  [4,] "AugAugAugAugAugAugAug"          "DecDecDecDecDecDecDec"         
#>  [5,] "Apr"                            "Jan"                           
#>  [6,] "OctOctOctOctOct"                "AugAugAugAugAug"               
#>  [7,] "MarMarMar"                      "AprAprApr"                     
#>  [8,] "SepSepSepSepSepSepSepSepSep"    "OctOctOctOctOctOctOctOctOct"   
#>  [9,] "MayMayMayMayMayMayMayMay"       "MarMarMarMarMarMarMarMar"      
#> [10,] "JulJulJulJul"                   "SepSepSepSep"                  
#> 
#> , , 2
#> 
#>       [,1]                             [,2]                            
#>  [1,] "FebFeb"                         "NovNov"                        
#>  [2,] "DecDecDecDecDecDec"             "JunJunJunJunJunJun"            
#>  [3,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"
#>  [4,] "AugAugAugAugAugAugAug"          "DecDecDecDecDecDecDec"         
#>  [5,] "Apr"                            "Jan"                           
#>  [6,] "OctOctOctOctOct"                "AugAugAugAugAug"               
#>  [7,] "MarMarMar"                      "AprAprApr"                     
#>  [8,] "SepSepSepSepSepSepSepSepSep"    "OctOctOctOctOctOctOctOctOct"   
#>  [9,] "MayMayMayMayMayMayMayMay"       "MarMarMarMarMarMarMarMar"      
#> [10,] "JulJulJulJul"                   "SepSepSepSep"                  
#> 
#> , , 3
#> 
#>       [,1]                             [,2]                            
#>  [1,] "FebFeb"                         "NovNov"                        
#>  [2,] "DecDecDecDecDecDec"             "JunJunJunJunJunJun"            
#>  [3,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"
#>  [4,] "AugAugAugAugAugAugAug"          "DecDecDecDecDecDecDec"         
#>  [5,] "Apr"                            "Jan"                           
#>  [6,] "OctOctOctOctOct"                "AugAugAugAugAug"               
#>  [7,] "MarMarMar"                      "AprAprApr"                     
#>  [8,] "SepSepSepSepSepSepSepSepSep"    "OctOctOctOctOctOctOctOctOct"   
#>  [9,] "MayMayMayMayMayMayMayMay"       "MarMarMarMarMarMarMarMar"      
#> [10,] "JulJulJulJul"                   "SepSepSepSep"