I'm trying to save an SVG image to a file path containing Unicode characters. For example:
n = c(2, 3, 5)
s = c("aa", "bb", "cc")
b = c(TRUE, FALSE, TRUE)
df = data.frame(n, s, b)
svg("c:/נועם/plots.svg")
plot(df)
dev.off()
Running this with Rscript.exe fails with the following error:
Error in plot.new() : cairo error 'error while writing to output stream'
How can I make it work?
You can set working directory to the directory with Hebrew name than save svg file. Please see the code below:
n <- c(2, 3, 5)
s <- c("aa", "bb", "cc")
b <- c(TRUE, FALSE, TRUE)
df <- data.frame(n, s, b)
setwd("C:\\נועם\\")
svg("plots.svg")
plot(df)
dev.off()
Late to the party but I think that wrapping the path in enc2native()
function normally solves encoding issues under Windows to my experience. In your case you should try
svg(enc2native("c:/נועם/plots.svg"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.