return a logical vector of the same length as x, indicating if elements are located before a set of entries to match or not.

before(x, entries)

Arguments

x

an atomic vector of values to be tested

entries

a sequence of items to be searched in x.

See also

Examples

library(flextable)
library(officer)

dat <- data.frame(
  stringsAsFactors = FALSE,
  check.names = FALSE,
  Level = c("setosa", "versicolor", "virginica", "<NA>", "Total"),
  Freq = as.integer(c(50, 50, 50, 0, 150)),
  `% Valid` = c(100/3,
                100/3,100/3,NA,100),
  `% Valid Cum.` = c(100/3, 100*2/3, 100, NA, 100),
  `% Total` = c(100/3,
                100/3,100/3,0,100),
  `% Total Cum.` = c(100/3,
                     100*2/3,100,100,100)
)

ft <- flextable(dat)
ft <- hline(ft, i = ~ before(Level, "Total"),
            border = fp_border_default(width = 2))
ft
#> a flextable object.
#> col_keys: `Level`, `Freq`, `% Valid`, `% Valid Cum.`, `% Total`, `% Total Cum.` 
#> header has 1 row(s) 
#> body has 5 row(s) 
#> original dataset sample: 
#>        Level Freq   % Valid % Valid Cum.   % Total % Total Cum.
#> 1     setosa   50  33.33333     33.33333  33.33333     33.33333
#> 2 versicolor   50  33.33333     66.66667  33.33333     66.66667
#> 3  virginica   50  33.33333    100.00000  33.33333    100.00000
#> 4       <NA>    0        NA           NA   0.00000    100.00000
#> 5      Total  150 100.00000    100.00000 100.00000    100.00000