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

bc_strrep(x, y)
#> , , 1
#> 
#>       [,1]                             [,2]                            
#>  [1,] "AugAugAugAugAug"                "MarMarMarMarMar"               
#>  [2,] "OctOctOctOctOctOctOctOctOctOct" "MayMayMayMayMayMayMayMayMayMay"
#>  [3,] "JunJunJunJunJunJunJunJun"       "AugAugAugAugAugAugAugAug"      
#>  [4,] "DecDecDecDecDecDecDec"          "OctOctOctOctOctOctOct"         
#>  [5,] "JanJanJan"                      "JunJunJun"                     
#>  [6,] "Feb"                            "Dec"                           
#>  [7,] "JulJulJulJulJulJulJulJulJul"    "JanJanJanJanJanJanJanJanJan"   
#>  [8,] "SepSep"                         "FebFeb"                        
#>  [9,] "NovNovNovNov"                   "JulJulJulJul"                  
#> [10,] "AprAprAprAprAprApr"             "SepSepSepSepSepSep"            
#> 
#> , , 2
#> 
#>       [,1]                             [,2]                            
#>  [1,] "AugAugAugAugAug"                "MarMarMarMarMar"               
#>  [2,] "OctOctOctOctOctOctOctOctOctOct" "MayMayMayMayMayMayMayMayMayMay"
#>  [3,] "JunJunJunJunJunJunJunJun"       "AugAugAugAugAugAugAugAug"      
#>  [4,] "DecDecDecDecDecDecDec"          "OctOctOctOctOctOctOct"         
#>  [5,] "JanJanJan"                      "JunJunJun"                     
#>  [6,] "Feb"                            "Dec"                           
#>  [7,] "JulJulJulJulJulJulJulJulJul"    "JanJanJanJanJanJanJanJanJan"   
#>  [8,] "SepSep"                         "FebFeb"                        
#>  [9,] "NovNovNovNov"                   "JulJulJulJul"                  
#> [10,] "AprAprAprAprAprApr"             "SepSepSepSepSepSep"            
#> 
#> , , 3
#> 
#>       [,1]                             [,2]                            
#>  [1,] "AugAugAugAugAug"                "MarMarMarMarMar"               
#>  [2,] "OctOctOctOctOctOctOctOctOctOct" "MayMayMayMayMayMayMayMayMayMay"
#>  [3,] "JunJunJunJunJunJunJunJun"       "AugAugAugAugAugAugAugAug"      
#>  [4,] "DecDecDecDecDecDecDec"          "OctOctOctOctOctOctOct"         
#>  [5,] "JanJanJan"                      "JunJunJun"                     
#>  [6,] "Feb"                            "Dec"                           
#>  [7,] "JulJulJulJulJulJulJulJulJul"    "JanJanJanJanJanJanJanJanJan"   
#>  [8,] "SepSep"                         "FebFeb"                        
#>  [9,] "NovNovNovNov"                   "JulJulJulJul"                  
#> [10,] "AprAprAprAprAprApr"             "SepSepSepSepSepSep"