There are a two ways to specify a casting formula: either as a string, or a list of quoted variables. This function converts the former to the latter.
parse_formula(formula = "... ~ variable", varnames, value.var = "value")Casting formulas separate dimensions with ~ and variables within
a dimension with + or *. . can be used as a
placeholder, and ... represents all other variables not otherwise
used.
reshape2:::parse_formula("a + ...", letters[1:6])
#> [[1]]
#> List of 6
#> $ a: symbol a
#> $ b: symbol b
#> $ c: symbol c
#> $ d: symbol d
#> $ e: symbol e
#> $ f: symbol f
#> - attr(*, "env")=<environment: 0x63d279830a68>
#> - attr(*, "class")= chr "quoted"
#>
reshape2:::parse_formula("a ~ b + d")
#> [[1]]
#> List of 1
#> $ a: symbol a
#> - attr(*, "env")=<environment: 0x63d2799c0da0>
#> - attr(*, "class")= chr "quoted"
#>
#> [[2]]
#> List of 2
#> $ b: symbol b
#> $ d: symbol d
#> - attr(*, "env")=<environment: 0x63d2799c0da0>
#> - attr(*, "class")= chr "quoted"
#>
reshape2:::parse_formula("a + b ~ c ~ .")
#> [[1]]
#> List of 2
#> $ a: symbol a
#> $ b: symbol b
#> - attr(*, "env")=<environment: 0x63d279b54540>
#> - attr(*, "class")= chr "quoted"
#>
#> [[2]]
#> List of 1
#> $ c: symbol c
#> - attr(*, "env")=<environment: 0x63d279b54540>
#> - attr(*, "class")= chr "quoted"
#>
#> [[3]]
#> list()
#> - attr(*, "env")=<environment: 0x63d279b54540>
#> - attr(*, "class")= chr "quoted"
#>