| 1 |
\name{annotations} |
| 2 |
\alias{annotation} |
| 3 |
\alias{annotation,ANY-method} |
| 4 |
\alias{annotation,item-method} |
| 5 |
\alias{annotation,data.set-method} |
| 6 |
\alias{annotation<-} |
| 7 |
\alias{annotation<-,ANY,NULL-method} |
| 8 |
\alias{annotation<-,ANY,character-method} |
| 9 |
\alias{annotation<-,ANY,annotation-method} |
| 10 |
\alias{annotation<-,item,annotation-method} |
| 11 |
\alias{annotation<-,vector,annotation-method} |
| 12 |
\alias{description} |
| 13 |
\alias{description,data.set-method} |
| 14 |
\alias{description,importer-method} |
| 15 |
\alias{description,data.frame-method} |
| 16 |
\alias{description,tbl_df-method} |
| 17 |
\alias{description<-} |
| 18 |
\alias{wording} |
| 19 |
\alias{wording<-} |
| 20 |
\alias{annotation-class} |
| 21 |
\alias{show,annotation-method} |
| 22 |
\title{Adding Annotations to Objects} |
| 23 |
\description{ |
| 24 |
Annotations, that is, objects of class \code{"annotation"}, |
| 25 |
are character vectors with all their elements named. |
| 26 |
Only one method is defined for this subclass of character vectors, |
| 27 |
a method for \code{\link{show}}, that shows the annotation in |
| 28 |
a nicely formatted way. Annotations of an object can be obtained |
| 29 |
via the function \code{annotation(x)} and can be set via |
| 30 |
\code{annotation(x)<-value}. |
| 31 |
|
| 32 |
Elements of an annotation with names \code{"description"} |
| 33 |
and \code{"wording"} have a special meaning. |
| 34 |
The first kind can be obtained and set via |
| 35 |
\code{description(x)} and \code{description(x)<-value}, |
| 36 |
the second kind can be obtained via |
| 37 |
\code{wording(x)} and \code{wording(x)<-value}. |
| 38 |
\code{"description"} elements are used in way the "variable labels" |
| 39 |
are used in SPSS and Stata. \code{"wording"} elements of annotation |
| 40 |
objects are meant to contain the question wording of a questionnaire |
| 41 |
item represented by an \code{"item"} objects. |
| 42 |
These elements of annotations are treated in a special way |
| 43 |
in the output of the \code{coodbook} function. |
| 44 |
} |
| 45 |
\usage{ |
| 46 |
annotation(x) |
| 47 |
\S4method{annotation}{ANY}(x) |
| 48 |
\S4method{annotation}{item}(x) |
| 49 |
\S4method{annotation}{data.set}(x) |
| 50 |
annotation(x)<-value |
| 51 |
\S4method{annotation}{ANY,character}(x)<-value |
| 52 |
\S4method{annotation}{ANY,annotation}(x)<-value |
| 53 |
\S4method{annotation}{item,annotation}(x)<-value |
| 54 |
\S4method{annotation}{vector,annotation}(x)<-value |
| 55 |
|
| 56 |
description(x) |
| 57 |
description(x)<-value |
| 58 |
|
| 59 |
wording(x) |
| 60 |
wording(x)<-value |
| 61 |
|
| 62 |
\S4method{description}{data.set}(x) |
| 63 |
\S4method{description}{importer}(x) |
| 64 |
\S4method{description}{data.frame}(x) |
| 65 |
\S4method{description}{tbl_df}(x) |
| 66 |
} |
| 67 |
\arguments{ |
| 68 |
\item{x}{an object} |
| 69 |
\item{value}{a character or annotation object} |
| 70 |
} |
| 71 |
\value{ |
| 72 |
\code{annotation(x)} returns an object of class \code{"annotation"}, |
| 73 |
which is a named character. |
| 74 |
\code{description(x)} and \code{wording(x)} each usually return a character string. |
| 75 |
If \code{description(x)} is applied to a \code{\link{data.set}} or an \code{\link{importer}} object, |
| 76 |
however, a character vector is returned, which is named after the |
| 77 |
variables in the data set or the external file. |
| 78 |
} |
| 79 |
\examples{ |
| 80 |
vote <- sample(c(1,2,3,8,9,97,99),size=30,replace=TRUE) |
| 81 |
labels(vote) <- c(Conservatives = 1, |
| 82 |
Labour = 2, |
| 83 |
"Liberal Democrats" = 3, |
| 84 |
"Don't know" = 8, |
| 85 |
"Answer refused" = 9, |
| 86 |
"Not applicable" = 97, |
| 87 |
"Not asked in survey" = 99 |
| 88 |
) |
| 89 |
missing.values(vote) <- c(97,99) |
| 90 |
description(vote) <- "Vote intention" |
| 91 |
wording(vote) <- "If a general election would take place next tuesday, |
| 92 |
the candidate of which party would you vote for?" |
| 93 |
annotation(vote) |
| 94 |
annotation(vote)["Remark"] <- "This is not a real questionnaire item, of course ..." |
| 95 |
codebook(vote) |
| 96 |
} |