I am working on submitting an R package and when I run
devtools::check()
I get the following warning:
W checking sizes of PDF files under ‘inst/doc’ (1.6s)
‘gs+qpdf’ made some significant size reductions:
compacted ‘Vignette1.pdf’ from 544Kb to 256Kb
compacted ‘Vignette2.pdf’ from 328Kb to 69Kb
consider running tools::compactPDF(gs_quality = "ebook") on these files
I understand that the size of the PDFs are the issue, and that they need to be resized, but can anyone explain to me where I need to place tools::compactPDF(gs_quality = "ebook") in my code so that when the vignettes are created this is not an issue. You cannot submit an R package that throws a warning so I need to come up with a solution to fix this.
If you do R CMD build --help you will see the two lines
--compact-vignettes= try to compact PDF files under inst/doc:
"no" (default), "qpdf", "gs", "gs+qpdf", "both"
Per recent discussion on the mailing lists, you may want arguments gs+qpdf or both. You may want to experiment with both. Use of the option should render a package that does not trigger the NOTE.
And I presume there is a way to pass that onto devtools as well but I am not familiar with its functions so I can't give you a direct pointer.
As of devtools 2.4.5
devtools::check(build_args = "--compact-vignettes=gs+qpdf")
is the correct parameterization. But note that for building, the corresponding call is now
devtools::build(args = "--compact-vignettes=gs+qpdf")
Note that in neither case do you quote the argument passed down to R CMD BUILD's --compact-vignettes
I just installed RStudio on Mac OS X, version 10.7.3.
After executing the following commands
library(ggplot2)
qplot(mpg, wt, data=mtcars)
I get the following error:
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Polygon edge not found
In addition: Warning messages:
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Arial"
2: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Arial"
How do I fix this?
this happened to me and i discovered that the arial font file had been disabled. first check to see if Arial.ttf has been moved to the disabled fonts directory. from the terminal:
ls /Library/Fonts\ Disabled
if so, move it back to the active fonts directory.
sudo mv /Library/Fonts\ Disabled/Arial.ttf /Library/Fonts
log out, log in, then open the 'Font Book' application. in my case, arial was present before hand, but it was the Microsoft version stored in /Library/fonts/Microsoft/. Font Book may now show a yellow triangle next to the font name, indicating that multiple copies of the font exist. highlight the font name and chose the Resolve Duplicates command from the Edit menu. this should disable the Microsoft copy, which you can confirm by selecting one of the arial type faces (click the expand triangle next to the font name), right-click on the one labelled Off, and choose Reveal in Finder, which should open a window to Microsoft fonts directory.
So I bumped into the same problem with a code that was working just a few weeks before, and no massive update of anything on the computer (except maybe the OS, now that I get to think about it...).
The way I solved it is that I forced the graphic window to open first by calling
quartz()
before my graphs, and it did the trick. Still unsure about the font, I seem to have the Arial in place.
After a few trials, I think this "fix" could help.
First try running this to ensure the fonts actually exist:
loadfonts(dev="win")
If they do, call the following to ensure the name you're calling is similar to that R knows:
windowsFonts()
Otherwise, try the following:
library(extrafont)
extrafont::font_import()
The above fixed problems for me. Hope someone in the future may be helped by the same.
After coming across the same problem again and again and trying different solutions I have decided to source the Arial font externally and add it to the Font Book. Prior to this exercise I had a number of fonts that came with MS Office, like Arial Black, Arial Narrow and so no but no plain Arial font visible. I'm guessing that this can be explained by the odd font policy that MS applications on Mac are applying, which is discussed in a greater detail here. Nevertheless, it appears that adding font externally solved the problem.
I added an extra parameter to my qqplot() function like this:
theme(text=element_text(family="Garamond", size=14))
and sure enough - got a chart. End result then is:
ggplot(train, aes(x = pclass, fill = factor(survived))) +
geom_bar() +
xlab("Pclass") +
ylab("Total Count") +
labs(fill = "Survived") +
theme(text=element_text(family="Garamond", size=14))
I did open Font Book and on my system (Mac OSX 10.12.3) is shows Arial as being off. I do have Microsoft apps installed including MS Excel but I cannot at this point correlate the disabling of any font with the install of any MS app.
HTH
As others have cited, this issue definitely seems to be related to a Microsoft Office upgrade (my company had just upgraded the software immediately before the issue surfaced).
After attempting to run a simple ggplot2 plot, I received the following Error and Warning:
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
Warning messages:
1: In grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) :
no font could be found for family "Arial"
I resolved this issue by performing the following actions:
(1) Open Font Book
(2) Navigate to the Arial Font
(3) Right Click -> "Restore Font"
Then the plot rendered perfectly.
I hope this helps!
For mac operating system, i tried many options but in the end following worked.
- open font book and remove disable (enable) arial fonts.
- restart the computer.
I've faceted the same issue and it was enough reseting the plot area (dev.off()).
I resolved by going to Font Book, going to File -> Restore Standard Fonts.
I ran into the same problem (interestingly, I received the error when calling the "spplot" function rather than any of the ggplot2 functions). Because I had recently installed MS Office for Mac, I tried disabling the MS duplicate Arial font as was previously suggested, but still received the error message repeatedly even after doing this. I ended up simply removing all MS Office duplicate fonts (Go-->Computer-->Macintosh HD--->Library-->Fonts and then move the Microsoft folder to the trash). I'm not sure what effect this will have on my MS applications, but it seems to have remedied my R issues, which is more important to me at this point anyway!
Working on MacOS, I got the same error message with the warnings mentioning instead of Arial the Roboto Condensed fonts. So I installed those, which removed the warnings, but not the error message.
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
Then I found at https://community.rstudio.com/t/still-fighting-with-grid-call-c-textbounds-as-graphicsannot-x-label-x-x-x-y-polygon-edge-not-found-error/65559 the tip to re-install X11 https://www.xquartz.org .
After that the error disappeared ... but it still did not plot when the code was in an R file. It does work, though, when I knit in RStudio from an R-markdown document.
I just ran into the same problem after updating my OS and a fresh install of MS Office, which seems to be the culprit.
Since I couldn't get the terminal approach to work, I simply went straight to the Font Book and enabled the disabled fonts (Arial, Times New Roman, Verdana) manually. After restarting, everything seems to be working fine now.
This strikes me as the most naïve solution but it's also easiest to implement imho.
I encountered a similar problem using the function:
ggarrange (ggpubr package)
It was solved by manually deactivating and activating the package (by clicking on the package in "packages"). Maybe this also helps others :)
Bizarre error. But for me, on mac, the solution was simple: simply update Xquartz.
Open spotlight search with cmd + space, search for Xquartz
Once, opened, go to about -> Check for updates -> Update.
I understand that both R console jobs and Rstudio started failing out in their graphics plotting duties, and that now when you run trivial plot request, you receive failure error, and no plot.
Have you reset the sessions ? (Ctrl+Shft+F10)
Sometimes sessions can get corrupted after all.
Alternatively, if you would like something else to try, before that route, it might be worth halting the graphics device. dev.off() and trying that elementary plot again.
Of course, if your issue is persistent, across to new sessions, then this answer does not apply.
First, as a quick test as to whether this error is the result of a font-related issue, you can try plotting without any text (see code below).
# test whether error is being generated by a font issue
library(ggplot2)
# try removing all fonts to test if issue is font-related
# by using theme(text = element_blank())
mtcars %>%
ggplot() +
aes(x = wt, y = mpg) +
geom_point() +
theme(text = element_blank())
Second, if the text-free version of your plot works and you're on a Mac, try reinstalling ggplot2. Recently, after trying all the other approaches, I found running install.packages("ggplot2") and restarting RStudio was the only thing that solved the problem.
Third, more than a year ago fixing Arial (as suggested above) was helpful:
Hit Command-Space and type Font Book to open that app
Right-click on Arial and select Disabled Arial
Right-click on Arial and select Enable Arial
When prompted to Resolve Duplicates select Resolve Automatically
Quit out of RStudio and re-open RStudio (I didn't need to reboot my computer)
Re-run plotting code as test (in my case it worked fine without the error)
I am trying to reproduce simple example with rCharts library to plot sankey chart. I found this example from scratch and tried to reproduce it, however, I came up with some problems.
Firstly I have tried running this code without nothing. Then I found out and realized, that I need d3_sankey in my computer. So, I have downloaded it from here and copied to C:\Users\adomas\Documents\R\win-library\3.0\rCharts\libraries\widgets\d3_sankey.
Then I've tried that unchanged code once more and still got the following error:
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '/config.yml': No such file or directory
Since that didn't help too, I have tried changing paths from:
sankeyPlot$setLib('libraries/widgets/d3_sankey')
sankeyPlot$setTemplate(script = "libraries/widgets/d3_sankey/layouts/chart.html")
to
sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey')
sankeyPlot$setTemplate(script = "C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html")
However, this time, the blank screen in Viewer appeared but no actual Sankey graph and I got the following in console:
Warning message:
In readLines(file, warn = warn, ...) :
invalid input found on input connection 'C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html
I have tried changing paths and etc, but still something is wrong. And I am not sure if I need to use sankeyPlot$setTemplate at all.
I want to use Sankey chart in my shiny application, but firstly I want to reproduce simply in R. Suggestions would help a lot!
Versions of libraries:
rCharts_0.4.2
igraph_0.7.0
R version: 3.0.2
EDITED:
I have tried this code on different system. And everything works there. Versions of libraries and R are the same and I've copied same documents and just specified full path. I have tried that again on my own computer, but still got the same error yet.
I've experienced the same issues. The solution for me was to upgrade rCharts :
devtools::install_github("rCharts", "ramnathv")
Second, I didn't include the sankeyPlot$setTemplate() line.
Finally, the path in $setLib() should be a direct path (as discribed in the solution of #adomasb or the following line can be used to link directly to the original github:
sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey/libraries/widgets/d3_sankey')
A downside of this last approach is that internet is always required to run the script.
Alright, eventually it works as it should be.
I just rebooted my system and that's it. However, if anyone would come up with same problem, just be sure you specify direct path, where you placed all necessary files for d3_sankey. Therefore, you rather use
sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey')
This is wonderful chart type. Good luck!
My paths and files are as follows ...
E:R/R-2.15.1/library/Rcmdr/
E:R/R-2.15.1/library/RcmdrPlugin.Package/
E:R/R-2.15.1/MyLibrary/RcmdrPlugin.Package.zip
E:R/R-2.15.1/MyLibrary/RcmdrPlugin.Package/
where, in the name RcmdrPlugin.Package, I've used the word 'Package' to represent the name of the actual package being used.
The installation is as described above because (i) I'm not an expert at installing packages, (ii) I couldn't do a direct install from Cran because I wanted to put the package onto a USB stick; and, (iii) at work the Cran server is blocked (sic).
When I start the package from the GUI the Cmdr opens once and quickly closes (I don't know if this is relevant or normal) and opens again. Once open, I can operate the package via the Cmdr interface. It's a very nice package, everything works really well until I want to save the work. Then I get the following error,
Error in obj[i] : object of type 'closure' is not subsettable
I've been in contact with the people who developed (and are still developing) the package and they cannot reproduce the bug.
I strongly suspect that the problem lies in my 'crappy' install and file configuration, rather than with the package.
Can anyone please help me by suggesting how I would undo what I've done and do it properly in view of the constraints list above?
I appreciate that I can use Remove to get rid of the package but I don't want to start tinkering with something without having a greater understanding of what I'm doing.
Lastly, note that is error has been discussed a number of times on this list but not within this particular context.
I've managed to get it to work by following the instructions from here stackoverflow.com/questions/12820189/… where I set repos=NULL after I'd put the package into /MyLibrary/
I created several hundred plots using ggplot and saved them all to a list. I saved the list to disk using:
save(list_of_plots,file="list_of_plots.rdata")
Now I want to display those plots and save some using ggsave. However, calling a list item just shows me components of the plot.
> names(plots00_t2[[1]])
[1] "data" "layers" "scales" "mapping" "options"
[6] "coordinates" "facet" "plot_env"
Update: My dumb mistake was not loading ggplot2 when I reopened these files. However, when attempting to display these plots, I get:
Error in get("make_aesthetics", env = x, inherits = TRUE)(x, ...) :
could not find function "calc_aesthetics"
So short of recreating these plots, how would I fix this?
the last version using the internal function calc_aesthetics was ggplot2 version 0.8.2. If possible, check which version of ggplot2 is used for creating the plots and load that one. Otherwise, try with version 0.8.2 or earlier.
Download the file from http://cran.r-project.org/src/contrib/Archive/ggplot2/ and save it somewhere on your computer (I used G:/Temp here). Then use this code to install and call the specific version :
install.packages(
"G:Temp/ggplot2_0.8.2.tar.gz",
lib="G:/Templibs",
repos=NULL,
type="source")
library(ggplot2,lib.loc="G:/Templibs")
After this, you should be able to print the graphs. See also this question and the help files of ?library and ?install.packages
It might happen that the code of ggplot2 was changed in meanwhile and "calc_aesthetics" is no longer available. In this case you should install an older version of ggplot2, to recover your work.
Though, the above is quite unlikely. The problem seems to stem from the fact that some parts of your plots have not been saved properly.
You should produce the traceback(), it might cast some light on the problem.