Learn R Programming

sjmisc (version 2.5.0)

set_note: Add notes (annotations) to (labelled) variables

Description

This function adds a note (string) as note-attribute to x.

Usage

set_note(x, value = NULL)

set_note(x) <- value

Arguments

x

Variable (vector).

value

The note (annotation) as character string that will be added as note-attribute to x.

Value

x, with value stored as attribute.

Examples

Run this code
# NOT RUN {
library(haven)
# create labelled factor
x <- labelled(c("M", "M", "F", "X", "N/A"),
              c(Male = "M", Female = "F",
                Refused = "X", "Not applicable" = "N/A"))

set_label(x) <- "A labelled vector with note"
set_note(x) <- "Test annotation."
get_note(x)
x

# }

Run the code above in your browser using DataLab