File: merge_v.Rd

package info (click to toggle)
r-cran-flextable 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,264 kB
  • sloc: sh: 15; makefile: 2
file content (81 lines) | stat: -rw-r--r-- 2,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/merge_flextable.R
\name{merge_v}
\alias{merge_v}
\title{Merge flextable cells vertically}
\usage{
merge_v(x, j = NULL, target = NULL, part = "body", combine = FALSE)
}
\arguments{
\item{x}{\code{flextable} object}

\item{j}{column to used to find consecutive values to be merged. Columns
from orignal dataset can also be used.}

\item{target}{columns names where cells have to be merged.}

\item{part}{partname of the table where merge has to be done.}

\item{combine}{If the value is TRUE, the columns defined by \code{j} will
be combined into a single column/value and the consecutive values of
this result will be used. Otherwise, the columns are inspected one
by one to perform cell merges.}
}
\description{
Merge flextable cells vertically when consecutive cells have
identical values. Text of formatted values are used to compare
values if available.

Two options are available, either a column-by-column algorithm or an
algorithm where the combinations of these columns are used once for all
target columns.
}
\section{Illustrations}{


\if{html}{\figure{fig_merge_v_1.png}{options: width="600"}}

\if{html}{\figure{fig_merge_v_2.png}{options: width="600"}}
}

\examples{
ft_merge <- flextable(mtcars)
ft_merge <- merge_v(ft_merge, j = c("gear", "carb"))
ft_merge

data_ex <- structure(list(srdr_id = c(
  "175124", "175124", "172525", "172525",
  "172545", "172545", "172609", "172609", "172609"
), substances = c(
  "alcohol",
  "alcohol", "alcohol", "alcohol", "cannabis",
  "cannabis", "alcohol\n cannabis\n other drugs",
  "alcohol\n cannabis\n other drugs",
  "alcohol\n cannabis\n other drugs"
), full_name = c(
  "TAU", "MI", "TAU", "MI (parent)", "TAU", "MI",
  "TAU", "MI", "MI"
), article_arm_name = c(
  "Control", "WISEteens",
  "Treatment as usual", "Brief MI (b-MI)", "Assessed control",
  "Intervention", "Control", "Computer BI", "Therapist BI"
)), row.names = c(
  NA,
  -9L
), class = c("tbl_df", "tbl", "data.frame"))


ft_1 <- flextable(data_ex)
ft_1 <- theme_box(ft_1)
ft_2 <- merge_v(ft_1, j = "srdr_id",
  target = c("srdr_id", "substances"))
  ft_2
}
\seealso{
Other flextable merging function: 
\code{\link{merge_at}()},
\code{\link{merge_h_range}()},
\code{\link{merge_h}()},
\code{\link{merge_none}()}
}
\concept{flextable merging function}