简体   繁体   中英

readPicture function (grImport package) not working on Linux (F22)

I'm trying to read an ps.xml file using grImport library ( http://cran.r-project.org/web/packages/grImport/vignettes/import.pdf ) Here is my code:

require("gridBase")
require("grImport")
require("plotrix")
petal <- readPicture("petal.ps.xml")

And this is the error I'm getting:

Error in if (x == 0) 1 else if (x == 1) 0 else x :                                                                                                        
missing value where TRUE/FALSE needed        

Here is my session information

> sessionInfo()
R version 3.2.0 (2015-04-16)                                                                                                                              
Platform: x86_64-redhat-linux-gnu (64-bit)                                                                                                                
Running under: Fedora 22 (Twenty Two)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] plotrix_3.5-12 grImport_0.9-0 XML_3.98-1.3   gridBase_0.4-7

The same code works on a Linux F20 with the following session information

> sessionInfo()
R version 3.2.0 (2015-04-16)                                                                                                                              
Platform: x86_64-redhat-linux-gnu (64-bit)                                                                                                                
Running under: Fedora 20 (Heisenbug)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] plotrix_3.4-8 grImport_0.8-4 XML_3.96-1.1   gridBase_0.4-6

I struggled with the same problem and eventually solved it by regenerating the xml with PostScriptTrace on the other platform. When comparing the files generated on the two platforms, I found that the failing image file was missing attributes in the path/context/style element. I was able to manually add the missing attributes lineend , linemitre , and linejoin and load the images.

I suspect that those missing elements are the source of the problem in some versions of grImport.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM