Could not find any X11 fonts error - r

I am starting to get into R development and I was following a tutorial that in a certain point opens the "X11" to display graphics but when that window opens I get the following error:
Error in axis(side = side, at = at, labels = labels, ...) : could
not find any X11 fonts Check that the Font Path is correct. In
addition: Warning messages: 1: In function (display = "", width,
height, pointsize, gamma, bg, : locale not supported by Xlib: some
X ops will operate in C locale 2: In function (display = "", width,
height, pointsize, gamma, bg, : X cannot set locale modifiers
I have been Googling around but I can't find how to fix the "font path" of this application, does anybody know?
EDIT
The output of sessionInfo():
> sessionInfo()
R version 2.13.2 (2011-09-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] C/UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] galgo_1.1 R.oo_1.8.2 R.methodsS3_1.2.1
loaded via a namespace (and not attached):
[1] tools_2.13.2
When doing names(X11Fonts()):
> names(X11Fonts())
[1] "serif" "sans" "mono"
>

I "followed" the admin manual, and set the lines in the .bashrc
Setting for the new UTF-8 terminal support in Lion.
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
From http://www.mail-archive.com/r-sig-mac#r-project.org/msg01027.html

What does this return:
capabilities("X11")
If you are on .Platform$OS.type == "windows" then you may need to do some further research. I doubt that X11 is installed there by default. But your edit shows that you are on a mac so try this:
names(X11Fonts())
# results on my device
[1] "serif" "sans" "mono" "Times"
[5] "Helvetica" "CyrTimes" "CyrHelvetica" "Arial"
[9] "Mincho"
When I execute X11() at the R command console in the Mac-GUI I get an X11 window and choosing X11/About X11' I see that I have "XQuartz 2.1.6 (xorg-server 1.4.2-apple33)". I am using Leopard (still), but I thought that recent version of Macs installed X11 support by default and I don't remember needing to point R in the right direction to find it either.

Related

dev='png' is not working for pdf output in knitr

In the default setting, knitr will use "'pdf' for LaTeX output and 'png' for HTML/markdown". However, I can specify the dev = "png" in the chunk options for the LaTeX output. This feature is very useful to reduce the file size for big vector figure (e.g. maps).
In the previous version of knitr (could be 1.8.*, but not sure), I can specify the dev = "png" (the example below is working for earlier version).
Today I installed the latest version of knitr from github (just now). But the dev='png' is not working for pdf output. I have to use png device for pdf output as I have some big vector figure in pdf format.
The error message is:
Error in (function (filename = "Rplot%03d.png", width = 480, height = 480, :
unused argument (pdf = list(useDingbats = FALSE) Call: <Anonymous> ...
block_exec -> chunk_device -> dev_new -> do.call -> <Anonymous> Execution halted))
How could I fix this problem?
This is my example:
---
output: pdf_document
---
```{r, echo=FALSE, dev='png'}
plot(cars)
```
Thanks for any advice. Please let me know if my question is still not clear.
This is my session information.
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.9.4
loaded via a namespace (and not attached):
[1] digest_0.6.4 evaluate_0.5.5 formatR_1.0 htmltools_0.2.6 rmarkdown_0.5.1 stringr_0.6.2
[7] tools_3.1.3 yaml_2.1.13
This is a bug in knitr. I just fixed it in the development version (v1.9.5). The reason for the failure was that the options for the pdf device were passed to the png device.

Function `Boot` from `R` package `car` can not find .carEnv

While using the Boot function from the car package I get the error message
Error in get(".y.boot", envir = .carEnv) : object '.carEnv' not found
I suspect I have inadvertently changed/set something in my OS and have no idea what it might be. Running the code below returns an error on my desktop but runs without error on a laptop running the same OS (Yosemite) as well as a desktop running Windows 7 (all using R-3.1.2). The code that triggers the message is
library(car)
swiss.lm <- lm(Fertility ~ Education, data = swiss)
BC <- Boot(swiss.lm, R = 999, method = "case") # No Problems
BR <- Boot(swiss.lm, R = 999, method = "residual") # Problems now
Error in get(".y.boot", envir = .carEnv) : object '.carEnv' not found
I have reinstalled R but the error still appears when running the above code. Any suggestions as to what I have done and how to get the code to run and find the environment would be most appreciated. TIA!
> 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 base
other attached packages:
[1] car_2.0-24
loaded via a namespace (and not attached):
[1] boot_1.3-15 grid_3.1.2 lattice_0.20-29 lme4_1.1-7 MASS_7.3- 37 Matrix_1.1-5
[7] mgcv_1.8-4 minqa_1.2.4 nlme_3.1-119 nloptr_1.0.4 nnet_7.3-9 parallel_3.1.2
[13] pbkrtest_0.4-2 quantreg_5.11 Rcpp_0.11.4 SparseM_1.6 splines_3.1.2 tools_3.1.2
Looks like a reproducible bug in a car package. According to package news the changes in latest version (2.0-24) are related to .carEnv handling.
I tried to get around the issue by simply assigning the .carEnv before call to Boot with
.carEnv <- car:::.carEnv
This makes the Boot function execute without errors, but I am not sure of any other effects.
The package maintainer emailed me and indicated a bug had been introduced in 2.0-24 and that he would attempt to fix the bug.

X11 forwarding over ssh for R: why this warning?

I need to use R (3.0.2 from pkgsrc) on a remote server (NetBSD) over a ssh connection with X11 forwarding. plot(1) is generating the expected graphic on my local machine, however R is also returning warnings in my terminal session as below.
> plot(1)
Warning messages:
1: In (function (display = "", width, height, pointsize, gamma, bg, :
locale not supported by Xlib: some X ops will operate in C locale
2: In (function (display = "", width, height, pointsize, gamma, bg, :
X cannot set locale modifiers
I don't know whether this bodes problems that I may encounter later, but I'd like to get everything set up and configured correctly. Would someone please clarify the meaning of the warnings and explain how to address them?
Edit for more info:
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64--netbsd (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
> names(X11Fonts())
[1] "serif" "sans" "mono" "Times" "Helvetica"
[6] "CyrTimes" "CyrHelvetica" "Arial" "Mincho"
The errors are saying that the X11 graphics driver does not know what font to use (see this discussion). By default, R installs with the C locale set. For linux, you need to set a UTF-8 locale which is prefixed by the language.
For example, for the English in the US, you would set it to 'en_US.UTF-8'.
Try setting the system locale with the Sys.setlocale command like so:
Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
Sys.setlocale("LC_ALL", "en_US.UTF-8")
This can be done through the .bashrc configuration file like so:
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
(source)

How to change the language of the messages using the package "gWidgetsRGtk2"

I'm making a GUI in R using the gWidgetsRGtk2 package and I need all messages in English but some appear to me in Spanish. For example:
w<- gwindow("Alert", width=100, height=100)
g <- ggroup(cont = w)
gimage("info", dirname="stock", size="large_toolbar", cont = g)
ig <- ggroup(horizontal = FALSE, cont = g)
glabel(message, cont = ig, expand = TRUE)
bg <- ggroup(cont = ig)
addSpring(bg)
gbutton("cancel", handler = function(h,...) dispose(w), cont = bg, toolkit = guiToolkit())
I need to change the word "Cancelar" to "Cancel".
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Spanish_Mexico.1252 LC_CTYPE=Spanish_Mexico.1252 LC_MONETARY=Spanish_Mexico.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Mexico.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] diagram_1.6.2 shape_1.4.0 cluster_1.14.4 plyr_1.8 ade4_1.5-2
[6] vegan_2.0-10 lattice_0.20-15 permute_0.8-0 gWidgetsRGtk2_0.0-82 RGtk2_2.20.25
[11] gWidgets_0.0-52
loaded via a namespace (and not attached):
[1] grid_3.0.1 tools_3.0.1
Thanks for all the suggestions, I could change the messages to English with this line of code:
Sys.setlocale(category = "LC_ALL", locale = "English")
Although this is an old question, that already has a solution I think this answer complements the previous solution.
For Windows 7 systems when RGui is started from an icon LANGUAGE="en" can be appended to Target.
Right click the icon and select properties.
Under the Shortcut tab find the Target field.
Append the LANGUAGE="en" to the path, separated by a space e.g. "C:\Program Files\R\R-3.4.1\bin\x64\Rgui.exe" LANGUAGE="en"
Bonus:
While you are in the icon properties it might be good to know that deleting the string in the Start in field makes the R working directory flexible - it will always be the same directory as the shortcut resides in. Copying the icon to e.g. "My R project" will make this the default directory when starting R using that icon.

why sometimes segfault in R when specifying custom linetypes?

Why do I get R-crashing segfaults when specifying custom linetypes in R? The four linetypes below are effectively identical, in that they cycle through the same size of dashes and spaces in the same order (they just start at different points in the cycle).
plot.new()
abline(0.1,0,lty='28282383') # works
abline(0.2,0,lty='83282823') # works
abline(0.3,0,lty='28238328') # segfault
abline(0.4,0,lty='23832828') # segfault
Here is the full error message for the first of the two deadly lines above:
*** caught segfault ***
address 0xbf981000, cause 'memory not mapped'
Segmentation fault
Looks like a bug in the Cairo graphics device - I get a crash with a default X11() graphics device but not with X11(type="Xlib") or pdf(). RStudio possibly works because it possibly uses its own methods to capture the graphics.
I don't see anything about this in the description of 2.15.1-patched:
http://cran.r-project.org/bin/windows/base/NEWS.R-2.15.1patched.html
so I tried that and have now reported it as a bug:
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15055
Seems to work for me via RStudio on a mac. What OS? What version of R?
> plot.new()
> abline(0.1,0,lty='28282383') # works
> abline(0.2,0,lty='83282823') # works
> abline(0.3,0,lty='28238328') # segfault
> abline(0.4,0,lty='23832828') # segfault
> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] C/en_US.UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reshape2_1.2.1
loaded via a namespace (and not attached):
[1] plyr_1.7.1 stringr_0.6.1 tools_2.15.0

Resources