# Basic usage with data frame (default .id column)
human_data <- data.frame(
.id = 1:10,
sentiment = sample(c("pos", "neg"), 10, replace = TRUE)
)
coder_a <- as_qlm_coded(human_data, name = "Coder_A")
coder_a
# Use custom id column with NSE (unquoted)
data_with_custom_id <- data.frame(
doc_id = 1:10,
sentiment = sample(c("pos", "neg"), 10, replace = TRUE)
)
coder_custom <- as_qlm_coded(data_with_custom_id, id = doc_id, name = "Coder_C")
# Or use quoted string
coder_custom2 <- as_qlm_coded(data_with_custom_id, id = "doc_id", name = "Coder_D")
# Create a gold standard from data frame
gold <- as_qlm_coded(
human_data,
name = "Expert",
is_gold = TRUE
)
# Validate with automatic gold detection
coder_b_data <- data.frame(
.id = 1:10,
sentiment = sample(c("pos", "neg"), 10, replace = TRUE)
)
coder_b <- as_qlm_coded(coder_b_data, name = "Coder_B")
# No need for gold = when gold object is marked (NSE works for 'by' too)
qlm_validate(coder_a, coder_b, gold = gold, by = sentiment, level = "nominal")
# Create from corpus object (simplified workflow)
data("data_corpus_manifsentsUK2010sample")
crowd <- as_qlm_coded(
data_corpus_manifsentsUK2010sample,
is_gold = TRUE
)
# Document names automatically become .id, all docvars included
# Use a docvar as identifier with NSE (unquoted)
crowd_party <- as_qlm_coded(
data_corpus_manifsentsUK2010sample,
id = party,
is_gold = TRUE
)
# Or use quoted string
crowd_party2 <- as_qlm_coded(
data_corpus_manifsentsUK2010sample,
id = "party",
is_gold = TRUE
)
# With complete metadata
expert <- as_qlm_coded(
human_data,
name = "expert_rater",
is_gold = TRUE,
codebook = list(
name = "Sentiment Analysis",
instructions = "Code overall sentiment as positive or negative"
),
metadata = list(
coder_name = "Dr. Smith",
coder_id = "EXP001",
training = "5 years experience",
date = "2024-01-15"
)
)
Run the code above in your browser using DataLab