Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-exhaustive translation list #8

Open
NFA opened this issue Feb 24, 2020 · 1 comment
Open

Non-exhaustive translation list #8

NFA opened this issue Feb 24, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@NFA
Copy link

NFA commented Feb 24, 2020

Hello,

I cam across this package when searching for a way to easily translate factors in R. The possibility to use a YAML file sold it. However, your package currently requires an exhaustive list of translations to function. Would you consider easing this restriction?

I have a data set of around 200+ factors of which I only need to translate 30-40.

E.g., It would be nice if the following could work:

library(labelmachine)

df <- data.frame(
  pupil_id = rep(1:4, each = 3),
  subject = rep(c("eng", "mat", "Gymnastics"), 4),
  result = c(1, 2, 2, NA, 2, NA, 1, 0, 1, 2, 3, NA),
  stringsAsFactors = FALSE
)

dict <- new_lama_dictionary(
  sub = c(eng = "English", mat = "Mathematics"),
  res = c(
    "1" = "Good",
    "2" = "Passed",
    "3" = "Not passed",
    "4" = "Not passed",
    NA_ = "Missed",
    "0" = NA
  )
)

df_new <- lama_translate(
    df,
    dict,
    subject_lab = sub(subject),
    result_lab = res(result)
  )

Which currently errors with:

Error: Error while calling 'lama_translate': Translation 'sub' could not be applied to column 'subject': The following values in the column variable could not be found in the translation: 'Gymnastics'.

/Kind regards/

@a-maldet a-maldet added the enhancement New feature or request label Feb 25, 2020
@a-maldet
Copy link
Owner

a-maldet commented Feb 25, 2020

Hi @NFA!

Good question. I totally see your use case. My primary consideration is the ux. I am a little bit afraid, that many users may expect wide range of possible behaviours regarding the ordering of the value levels without translation mapping. I need some time to think about the different use cases.
Right now, I am quite busy, but I will have a look into it soon.

@a-maldet a-maldet reopened this Feb 25, 2020
@a-maldet a-maldet self-assigned this Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants