s-u / Cairo

R graphics device using cairo graphics library for creating high-quality output
12 stars 10 forks source link

~ in filename causes error #12

Closed AMChalkie closed 7 years ago

AMChalkie commented 9 years ago

R.3.1.2.>library("Cairo") R.3.1.2.>Cairo.capabilities() png jpeg tiff pdf svg ps x11 win raster TRUE TRUE FALSE TRUE TRUE TRUE TRUE FALSE TRUE R.3.1.2.>filename <- "~/test.pdf" R.3.1.2.>Cairo(filename,dpi = 120,width = 400,height = 400,type = "pdf",) Error in Cairo(filename, dpi = 120, width = 400, height = 400, type = "pdf", : Failed to create Cairo backend! R.3.1.2.>plot.new() R.3.1.2.>text(x=.5,y=.5,labels="\u0260",family="Times New Roman") R.3.1.2.>dev.off() null device 1 R.3.1.2.> R.3.1.2.>filename <- "/Users/achalk/test2.pdf" R.3.1.2.>Cairo(filename,dpi = 120,width = 400,height = 400,type = "pdf",) R.3.1.2.>plot.new() R.3.1.2.>text(x=.5,y=.5,labels="\u0260",family="Times New Roman") R.3.1.2.>dev.off() null device 1 R.3.1.2.>sessionInfo() R version 3.1.2 (2014-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods
[7] base

other attached packages: [1] Cairo_1.5-6

loaded via a namespace (and not attached): [1] tools_3.1.2

AMChalkie commented 9 years ago

And my hacky way of resolving it. tildeRemover <- function(filename=NULL){ stopifnot(!is.null(filename)) tilde <- system("echo ~/.",intern=TRUE) filename <- gsub(pattern = "~",replacement = tilde,x=filename)

return(filename) }

s-u commented 8 years ago

I suspect what you really want is path.expand()