ropensci / git2rdata

An R package for storing and retrieving data.frames in git repositories.
https://ropensci.github.io/git2rdata/
GNU General Public License v3.0
99 stars 12 forks source link

write_vc() & relabel() get stuck when rewriting factor with an empty-string level #24

Closed florisvdh closed 5 years ago

florisvdh commented 5 years ago

It is what the title says: in the odd case where one factor level is an empty string, strange things happen (see html-notebook).

with write_vc():

  1. writing the dataframe for the first time, and reading it back in poses no problem: the same dataframe is returned. Also, existing NA-values for the factor are handled well, and distinguished from the empty-string level.
  2. however writing it (unchanged) for the second time gives the error:
Error: new factor labels for var
new indices labels for var
  1. when adding strict = FALSE (which shouldn't be needed), it appears that the empty string is replaced by NA values, resulting in potentially large diffs (which, in my real case, is my problem at hand)

When relabelling the level with relabel(), an extra label is added in the yml file; the old label remains and indices remain unchanged.

ThierryO commented 5 years ago

Thanks for reporting this bug. I'll look into this.

florisvdh commented 5 years ago

Thanks for fixing this!