You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Came across this in real data (sorry, cannot reproduce the data generation, too complicated). However, this reprex shows that having a variable with a zero-length string causes CHARSXP to fail (understandably).
library(haven)
data<- structure(list(not_working= structure(5:1, format.stata="%10.0g", label=character(0)),
working=1:5), row.names= c(NA, -5L), class= c("tbl_df", "tbl", "data.frame"))
haven::write_dta(data, tempfile(fileext=".dta")) # Not working, due to not_working#> Error in write_dta_(data_out, normalizePath(path, mustWork = FALSE), version = stata_file_format(version), : 'Rf_translateCharUTF8' must be called on a CHARSXP, but got 'NULL'haven::write_dta(data[, "working", drop=FALSE], tempfile(fileext=".dta")) #Works!
Came across this in real data (sorry, cannot reproduce the data generation, too complicated). However, this reprex shows that having a variable with a zero-length string causes CHARSXP to fail (understandably).
Created on 2023-11-15 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: