Skip to content

parse_formula() is not robust to variable names with a - sign #6

Description

@Christophe-Regouby

Current behavior

Depending of the variable name characters, plotluck() may wrongly interpret formula as invalid. a variable name with the minus sign will make plotluck fails with

Error in parse.formula(formula) : 
  Invalid formula: only one dependent variable allowed

Expected behavior

Allow variable names with - sign

ReprEx

library(plotluck)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(gapminder)
gapminder <- gapminder |> rename(`int-year` = "year")
plotluck(gapminder, .~1)
#> Factor variable country has too many levels (142), truncating to 30
#> Error in parse.formula(formula): Invalid formula: only one dependent variable allowed

Created on 2025-01-29 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions