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

bc_strrep(x, y)
#> , , 1
#> 
#>       [,1]                             [,2]                            
#>  [1,] "JunJunJunJunJunJunJunJunJunJun" "SepSepSepSepSepSepSepSepSepSep"
#>  [2,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [3,] "JulJulJul"                      "JunJunJun"                     
#>  [4,] "May"                            "Feb"                           
#>  [5,] "JanJanJanJanJanJan"             "JulJulJulJulJulJul"            
#>  [6,] "DecDecDecDecDec"                "MayMayMayMayMay"               
#>  [7,] "OctOctOctOct"                   "JanJanJanJan"                  
#>  [8,] "MarMarMarMarMarMarMar"          "DecDecDecDecDecDecDec"         
#>  [9,] "NovNov"                         "OctOct"                        
#> [10,] "AprAprAprAprAprAprAprAprApr"    "MarMarMarMarMarMarMarMarMar"   
#> 
#> , , 2
#> 
#>       [,1]                             [,2]                            
#>  [1,] "JunJunJunJunJunJunJunJunJunJun" "SepSepSepSepSepSepSepSepSepSep"
#>  [2,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [3,] "JulJulJul"                      "JunJunJun"                     
#>  [4,] "May"                            "Feb"                           
#>  [5,] "JanJanJanJanJanJan"             "JulJulJulJulJulJul"            
#>  [6,] "DecDecDecDecDec"                "MayMayMayMayMay"               
#>  [7,] "OctOctOctOct"                   "JanJanJanJan"                  
#>  [8,] "MarMarMarMarMarMarMar"          "DecDecDecDecDecDecDec"         
#>  [9,] "NovNov"                         "OctOct"                        
#> [10,] "AprAprAprAprAprAprAprAprApr"    "MarMarMarMarMarMarMarMarMar"   
#> 
#> , , 3
#> 
#>       [,1]                             [,2]                            
#>  [1,] "JunJunJunJunJunJunJunJunJunJun" "SepSepSepSepSepSepSepSepSepSep"
#>  [2,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [3,] "JulJulJul"                      "JunJunJun"                     
#>  [4,] "May"                            "Feb"                           
#>  [5,] "JanJanJanJanJanJan"             "JulJulJulJulJulJul"            
#>  [6,] "DecDecDecDecDec"                "MayMayMayMayMay"               
#>  [7,] "OctOctOctOct"                   "JanJanJanJan"                  
#>  [8,] "MarMarMarMarMarMarMar"          "DecDecDecDecDecDecDec"         
#>  [9,] "NovNov"                         "OctOct"                        
#> [10,] "AprAprAprAprAprAprAprAprApr"    "MarMarMarMarMarMarMarMarMar"