Skip to contents

Make a column into a list column

Usage

add_list_column(
  data,
  ...,
  type = c("1", "a", "A", "I", "i"),
  sep = ". ",
  merge = FALSE
)

Arguments

data

data.frame or tibble

...

Column name or tidyselect function. Select columns. Default is first column

type

list type. Can be "1" (numeric), "a" (lowercase alphabetical), or "ABC" (uppercase alphabetical), "i" (lowercase Roman numerals), "I" (uppercase Roman numerals)

sep

separator

merge

If TRUE, list columns will be united with their respective text columns.

Value

data.frame

Examples

d <- data.frame(x = letters[1:5], y = letters[2:6])
# default is first column
add_list_column(d) |>
  apa_flextable()
#> Registered S3 method overwritten by 'ftExtra':
#>   method                  from     
#>   as_flextable.data.frame flextable

x

y

1. 

a

b

2. 

b

c

3. 

c

d

4. 

d

e

5. 

e

f

# select any column add_list_column(d, y) |> apa_flextable()

x

y

a

1. 

b

b

2. 

c

c

3. 

d

d

4. 

e

e

5. 

f

add_list_column(d, type = "a", sep = ") ") |> apa_flextable()

x

y

a)

a

b

b)

b

c

c)

c

d

d)

d

e

e)

e

f

add_list_column(d, merge = TRUE) #> x y #> 1 1. a b #> 2 2. b c #> 3 3. c d #> 4 4. d e #> 5 5. e f