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

create_itemsInLevel cannot be used on levels with multiple attributes #257

Open
FredrikKarlssonSpeech opened this issue Jan 1, 2022 · 0 comments

Comments

@FredrikKarlssonSpeech
Copy link

There are I think several issues with this function.

First, the description on how the function is supposed to be used needs some attention.

What is stated clearly in the help for the function is, however, that if you want to insert an ITEM/SEGMENT/EVENT onto a level with multiple attribute definitions, then you need to specify a label for each attribute. If I try, however, I get these errors:

> rlang::last_error()
<error/tibble_error_incompatible_size>
Tibble columns must have compatible sizes.
* Size 0: Existing data.
* Size 3: Column `attribute`.
ℹ Only values of size one are recycled.
Backtrace:
  [.... my function's calls removed to avoid confusion...]

  8. dplyr::tibble(...)
  9. tibble:::tibble_quos(xs, .rows, .name_repair)
 10. tibble:::vectbl_recycle_rows(res, first_size, j, given_col_names[[j]])

If I have multiple attributes defined for a level I cannot insert them individually, so there seem to be checks in place
Error: Error in item 0000:msajc003:Intsint:1. The provided attributes (Intsint) do not match the attributes required (Intsint, Momel, IntsintMomel) for the level (Intsint).

indicating that the case of multiple attributes has been considered also in the code. Inserting labels into a level with just a single attribute defined works fine.

Looking at the code I also see checks that I think make little sense:

attributeName = unique(itemsToCreate$attribute)
if(length(levelName) > 1){
stop("'itemsToCreate' contains multiple attributes! The created ITEMs have to be on the same attribute!")
}

I dont see why the function should check if the number of levels is> 0 again here. It is not just a simple error of variable checked since the number of unique attributes should actually be more than one if required by the attribute definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant