Take the 2-minute tour ×

I'm trying to open a pdf file from R. For this I'm using the opedPDF() function from the Biobase package. It works well if the path to file does not contain spaces between words (e.g. "/Users/Admin/Desktop/test.pdf") but it does not work if the path contains spaces (e.g. /Users/Admin/Desktop/My Project/test.pdf). How can I make it accept any path or how should I automatically transform a given path such that is recognised by openPDF()? I would also like it to work on both mac and windows. Here is the code:

openPDF(paste(getwd(), "/test.pdf", sep=""))
share|improve this question

1 Answer 1

It's a bug in openPDF. You can work around it by calling normalizePath.


For the record, openPDF is just a wrapper to shell.exec under Windows so you can just call that instead.

share|improve this answer
I tried it and it still doesn't work openPDF(normalizePath(c(getwd(), "test.pdf"))) –  aymer Sep 5 '13 at 16:47
Try: openPDF(normalizePath(file.path(getwd(), "test.pdf"))) or just openPDF(normalizePath("test.pdf")) as was suggested. –  Tyler Rinker Sep 5 '13 at 17:18
still not working. I didn't mention that I'm using a mac. –  aymer Sep 6 '13 at 9:31
I've no Mac to test this, so you'll have to try a few things for me. Does shortPathName exist on the Mac? If so, try openPDF(shortPathName("test.pdf")). Also try openPDF(shQuote("test.pdf")). –  Richie Cotton Sep 6 '13 at 14:00

Your Answer


