# NOT RUN {
# initialize lama_dictinoary
dict <- new_lama_dictionary(
subject = c(en = "English", ma = "Mathematics"),
result = c("1" = "Very good", "2" = "Good", "3" = "Not so good")
)
## Example-1: mutate and append with 'lama_mutate'
# add a few subjects and a few grades
dict_new <- lama_mutate(
dict,
subject = c(bio = "Biology", subject, sp = "Sports"),
result = c("0" = "Beyond expectations", result, "4" = "Failed", NA_ = "Missed")
)
# the subjects "Biology" and "Sports" were added
# and the results "Beyond expectations", "Failed" and "Missed"
dict_new
## Example-2: delete with 'lama_mutate'
dict_new <- lama_mutate(
dict,
subject = NULL
)
dict_new
## Example-3: Alter and append with 'lama_mutate_'
# generate the new translation (character string)
subj <- c(
bio = "Biology",
lama_get(dict, subject),
sp = "Sports"
)
# save the translation under the name "subject"
dict_new <- lama_mutate_(
dict,
key = "subject",
translation = subj
)
# the translation "subject" now also contains
# the subjects "Biology" and "Sports"
dict_new
## Example-4: Delete with 'lama_mutate_'
# save the translation under the name "subject"
dict_new <- lama_mutate_(
dict,
key = "subject",
translation = NULL
)
# the translation "subject" was deleted
dict_new
# }
Run the code above in your browser using DataLab