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

bc_strrep(x, y)
#> , , 1
#> 
#>       [,1]                             [,2]                            
#>  [1,] "SepSepSepSepSepSep"             "MayMayMayMayMayMay"            
#>  [2,] "OctOctOct"                      "JulJulJul"                     
#>  [3,] "Jun"                            "Sep"                           
#>  [4,] "AprAprAprAprAprAprApr"          "OctOctOctOctOctOctOct"         
#>  [5,] "MarMarMarMar"                   "JunJunJunJun"                  
#>  [6,] "AugAug"                         "AprApr"                        
#>  [7,] "DecDecDecDecDecDecDecDecDec"    "MarMarMarMarMarMarMarMarMar"   
#>  [8,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [9,] "NovNovNovNovNov"                "DecDecDecDecDec"               
#> [10,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"
#> 
#> , , 2
#> 
#>       [,1]                             [,2]                            
#>  [1,] "SepSepSepSepSepSep"             "MayMayMayMayMayMay"            
#>  [2,] "OctOctOct"                      "JulJulJul"                     
#>  [3,] "Jun"                            "Sep"                           
#>  [4,] "AprAprAprAprAprAprApr"          "OctOctOctOctOctOctOct"         
#>  [5,] "MarMarMarMar"                   "JunJunJunJun"                  
#>  [6,] "AugAug"                         "AprApr"                        
#>  [7,] "DecDecDecDecDecDecDecDecDec"    "MarMarMarMarMarMarMarMarMar"   
#>  [8,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [9,] "NovNovNovNovNov"                "DecDecDecDecDec"               
#> [10,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"
#> 
#> , , 3
#> 
#>       [,1]                             [,2]                            
#>  [1,] "SepSepSepSepSepSep"             "MayMayMayMayMayMay"            
#>  [2,] "OctOctOct"                      "JulJulJul"                     
#>  [3,] "Jun"                            "Sep"                           
#>  [4,] "AprAprAprAprAprAprApr"          "OctOctOctOctOctOctOct"         
#>  [5,] "MarMarMarMar"                   "JunJunJunJun"                  
#>  [6,] "AugAug"                         "AprApr"                        
#>  [7,] "DecDecDecDecDecDecDecDecDec"    "MarMarMarMarMarMarMarMarMar"   
#>  [8,] "FebFebFebFebFebFebFebFeb"       "AugAugAugAugAugAugAugAug"      
#>  [9,] "NovNovNovNovNov"                "DecDecDecDecDec"               
#> [10,] "JanJanJanJanJanJanJanJanJanJan" "FebFebFebFebFebFebFebFebFebFeb"