ignore.case
isn't an argument in dplyr::filter()
.
You could force both sides of the logical expression to be the same case?
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
dat = tibble(locations = "Chelmsford",
pop = 123)
# correct case
.location = "Chelmsford"
dat |> filter(locations == .location)
#> # A tibble: 1 x 2
#> locations pop
#> <chr> <dbl>
#> 1 Chelmsford 123
# incorrect cases
.location = "CHELMSFORD"
dat |> filter(toupper(locations) == toupper(.location))
#> # A tibble: 1 x 2
#> locations pop
#> <chr> <dbl>
#> 1 Chelmsford 123
.location = "chelmsford"
dat |> filter(toupper(locations) == toupper(.location))
#> # A tibble: 1 x 2
#> locations pop
#> <chr> <dbl>
#> 1 Chelmsford 123
.location = "ChElMsFoRd"
dat |> filter(toupper(locations) == toupper(.location))
#> # A tibble: 1 x 2
#> locations pop
#> <chr> <dbl>
#> 1 Chelmsford 123
Created on 2022-03-07 by the reprex package (v2.0.1)