na for write_csv would be cool #187
Comments
Why not do: df[is.na(df)] <- ""
write_csv() IMHO this is clearer to understand at a glance and you keep data output and data mutation as distinct as possible. |
That's neat! I didn't know d <- data.frame(x = as.factor(c('foo', NA)))
d[is.na(d)] <- " "
#> Warning message:
#> In `[<-.factor`(`*tmp*`, thisvar, value = " ") :
#> invalid factor level, NA generated and it also has the side effect of type casting integer, double and logical columns to character: e <- data.frame(i = as.integer(c(1, NA)), d = c(0.5, NA), l = c(T, NA))
e[is.na(e)] <- " "
str(e)
#> 'data.frame': 2 obs. of 3 variables:
#> $ i: chr "1" " "
#> $ d: chr "0.5" " "
#> $ l: chr "TRUE" " " I'm with @ckluss on this one, I think an |
+1. |
write_csv(..., na="")
The text was updated successfully, but these errors were encountered: