| 1 |
\name{deduplicate_labels} |
| 2 |
\alias{deduplicate_labels} |
| 3 |
\alias{deduplicate_labels.item} |
| 4 |
\alias{deduplicate_labels.item.list} |
| 5 |
\title{Handle duplicated labels} |
| 6 |
\description{ |
| 7 |
The function \code{deduplicate_labels} can be used with "item" objects, |
| 8 |
"importer" objects or "data.set" objects to deal with |
| 9 |
duplicate labels, |
| 10 |
i.e. labels that are attached to more than |
| 11 |
one code. There are several ways to de-duplicate labels: by combining |
| 12 |
values that share their label or by making labels duplicate labels distinct. |
| 13 |
} |
| 14 |
\usage{ |
| 15 |
deduplicate_labels(x,\dots) |
| 16 |
\S3method{deduplicate_labels}{item}(x, |
| 17 |
method=c("combine codes", |
| 18 |
"prefix values", |
| 19 |
"postfix values"),\dots) |
| 20 |
# Applicable to 'importer' objects and 'data.set' objects |
| 21 |
\S3method{deduplicate_labels}{item.list}(x,\dots) |
| 22 |
} |
| 23 |
\arguments{ |
| 24 |
\item{x}{an item with value labels or that contains items with |
| 25 |
value labels} |
| 26 |
\item{method}{a character string that determines the method to |
| 27 |
make value labels unique.} |
| 28 |
\item{\dots}{other arguments, passed to specific methods of the |
| 29 |
generic function.} |
| 30 |
} |
| 31 |
\value{The function \code{deduplicate_labels} a copy of \code{x} |
| 32 |
that has unqiue value labels. |
| 33 |
} |
| 34 |
\examples{ |
| 35 |
x1 <- as.item(rep(1:5,4), |
| 36 |
labels=c( |
| 37 |
A = 1, |
| 38 |
A = 2, |
| 39 |
B = 3, |
| 40 |
B = 4, |
| 41 |
C = 5 |
| 42 |
), |
| 43 |
annotation = c( |
| 44 |
description="Yet another test" |
| 45 |
)) |
| 46 |
|
| 47 |
x2 <- as.item(rep(1:4,5), |
| 48 |
labels=c( |
| 49 |
i = 1, |
| 50 |
ii = 2, |
| 51 |
iii = 3, |
| 52 |
iii = 4 |
| 53 |
), |
| 54 |
annotation = c( |
| 55 |
description="Still another test" |
| 56 |
)) |
| 57 |
|
| 58 |
x3 <- as.item(rep(1:2,10), |
| 59 |
labels=c( |
| 60 |
a = 1, |
| 61 |
b = 2 |
| 62 |
), |
| 63 |
annotation = c( |
| 64 |
description="Still another test" |
| 65 |
)) |
| 66 |
|
| 67 |
codebook(deduplicate_labels(x1)) |
| 68 |
codebook(deduplicate_labels(x1,method="prefix")) |
| 69 |
codebook(deduplicate_labels(x1,method="postfix")) |
| 70 |
|
| 71 |
ds <- data.set(x1,x2,x3) |
| 72 |
codebook(deduplicate_labels(ds)) |
| 73 |
codebook(deduplicate_labels(ds,method="prefix")) |
| 74 |
codebook(deduplicate_labels(ds,method="postfix")) |
| 75 |
|
| 76 |
} |