Skip to contents

Chop Vector by Group

Usage

gchop(v, g)

Arguments

v

<character> vector

g

<integer> group

Value

<list>

Examples

(v <- random_hcpcs(2))
#>  [1] "4"     "P"     "F"     "G"     "S"     "Q4"    "G9"    "L57"   "965"  
#> [10] "2133"  "C188"  "33222" "Q4323"

(g <- sample(1:2, size = length(v), replace = TRUE))
#>  [1] 1 2 1 1 1 2 1 2 2 1 1 2 2

gchop(v, g)
#> [[1]]
#> [1] "4"
#> 
#> [[2]]
#> [1] "P"
#> 
#> [[3]]
#> [1] "F" "G" "S"
#> 
#> [[4]]
#> [1] "Q4"
#> 
#> [[5]]
#> [1] "G9"
#> 
#> [[6]]
#> [1] "L57" "965"
#> 
#> [[7]]
#> [1] "2133" "C188"
#> 
#> [[8]]
#> [1] "33222" "Q4323"
#>