DeclareDesign/fabricatr

comma bugs

Closed this issue · 2 comments

Some bugs from misplaced commas (see also DeclareDesign/DeclareDesign#175)

pop <- fabricate(
  upper_level = add_level(
    N = 50
  ),
  
  lower_level = add_level(
    N = 1,
  )
  
)

pop()
> Error in nest_level_internal(N = N, ID_label = ID_label, working_environment_ = working_environment_,  : 
  Nested data length for the variable "" appears to be incorrect. Nested data must either inherit the length N or be fixed-length variables equal to the total number of observations at the outer level. (In this case, 50). Variable supplied was length 0 


pop <- fabricate(
  upper_level = add_level(
    N = 50,
  ),
  
  lower_level = add_level(
    N = 1
  )
  
)

pop()
> Error in add_level_internal(N = N, ID_label = ID_label, working_environment_ = working_environment_,  : 
  All variables inside an add_level call must be named. 

Both types of bug are closed in the commit I just made with pretty good warning messages (good detail on which variable wasn't named, and a special case for the hanging comma at the end.) I also added the check in nest/modify. Tests are also commited with this commit. Close when merged.