How to correctly print μ by write_csv?

Viewed 189

write_csv() in readr outputs μ as µ. How to correctly output μ using write_csv()?

library(tidyverse)
x <- tribble(~x, 'µ')
write_csv(x, 'test.csv')

enter image description here

2 Answers

write_csv() will work correctly when the characters in tibble are in raw byte with UTF-8 Encoding.

library(tidyverse)
x <- tribble(~x, '\xb5')
Encoding(x$x) <- 'UTF-8'
write_csv(x, 'test.csv')

Try to set the correct fileEncoding = UTF

write.csv(x, 'test.csv', fileEncoding = "UTF-16")
Related