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.
Related
I am having an issue with the emf() function from the devEMF package.
The code I am using -
library(devEMF)
emf(file = "trial.emf")
plot(1:10, seq(10, 100, 10), type = "l", xlab = "Time", ylab = "Distance")
#sample plot
dev.off()
This does not have the plot line but does have everything else (labels, axis ticks, title).
Am I missing some graphics package?
sessionInfo()
#R version 3.3.2 (2016-10-31)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 7 x64 (build 7601) Service Pack 1
#locale:
#[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United #
#States.1252
#[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
#[5] LC_TIME=English_United States.1252
#attached base packages:
#[1] stats graphics grDevices utils datasets methods base
#other attached packages:
#[1] devEMF_3.6
#loaded via a namespace (and not attached):
#[1] tools_3.3.2
Some of the defaults in that function are not ideal if you are trying to view outside of LibreOffice.
try this:
library(devEMF)
emf(file = "trial.emf", emfPlus = FALSE)
plot(1:10, seq(10, 100, 10), type = "l", xlab = "Time", ylab = "Distance")
dev.off()
Make sure that emfPlus = FALSE. If you view the plot generated by emfPlus = TRUE in LibreOffice you will see it looks fine. Use emfPlus = FALSE when working with other viewers.
Most likely the program being used to view the resulting emf graphic does not support EMF+ records.
As alluded in JMT2080AD's answer, the devEMF library can produce either "EMF" or "EMF+" files. The newer EMF+ format (https://msdn.microsoft.com/en-us/library/cc230724.aspx) has been around since 2007 and is supported by more recent closed-source programs (i.e., Office 2010) but support is missing from old programs (e.g., older versions of Adobe Illustrator) and spotty in many open-source programs (e.g., LibreOffice, Inkscape).
For better or for worse, EMF+ records are embedded within EMF comment records, which means older programs will silently ignore them.
I find that the devEMF defaults produce acceptable files for Microsoft Office 2010 and LibreOffice >5.1.6. While LibreOffice support for EMF+ is incomplete, the unsupported features are turned off by default in the call to emf(). That said, JMT2080AD's suggestion of setting emfPlus = FALSE in the call to emf() is likely to make the files viewable by more programs (at the cost of losing features such as transparency and anti-aliasing).
(Disclosure: I am the author of the devEMF package)
When using R Studio, I usually just work with an .R file stacked on top of the Console. I keep the other panes (Environment, History, Files, etc) hidden.
But whenever I plot a graph, the other panes automatically pop out of the side bar to show me the Plot pane. Because I work on a laptop, this makes everything too small to see. By clicking the Zoom button on the Plots pane, I can get the plot also show up in a new window, but does not prevent the Plots pane from showing up.
Is there a way to "disable" the Plots pane in R Studio, and force plots show up in a new window?
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] ggplot2_2.2.1 jsonlite_1.4
[3] data.table_1.10.4
loaded via a namespace (and not attached):
[1] labeling_0.3 colorspace_1.2-6
[3] scales_0.4.1 lazyeval_0.2.0
[5] plyr_1.8.4 tools_3.2.3
[7] gtable_0.1.2 tibble_1.3.0
[9] curl_2.5 Rcpp_0.12.10
[11] grid_3.2.3 munsell_0.4.2
>
The dev.new() function will open a new plot window, which then becomes the target for all plots.
If you wish to open another window you can run the command a second time to open a second window.
dev.off() will shut down the window (in the order they were opened by default).
You can see how to control multiple graphics devices in the documentation here.
In RStudio, the default graphics device is normally "RStudioGD". You can change that to something else: the normal choices are "windows" on Windows, "quartz" on MacOS, "X11" on Linux. So for example, use
options(device = "quartz")
in your RStudio session on a Mac and you'll get the regular MacOS graphics window.
Try using the windows command before your plot call.
windows();(mpg ~ wt, mtcars)
The plot should pop-up in its own window whilst the pane stays minimized.
Commenting the following lines in C:\Program Files\RStudio\R\Tools.R seems to work (it may be necessary to edit the file as administrator):
# set our graphics device as the default and cause it to be created/set
.rs.addFunction( "initGraphicsDevice", function()
{
# options(device="RStudioGD")
# grDevices::deviceIsInteractive("RStudioGD")
grDevices::deviceIsInteractive()
})
If you want all plots in the current script to appear on a separate window, this should do the job:
dev.new(noRStudioGD = TRUE)
*Tested on RStudio version 1.4.1106 for Windows with R version 4.0.5 (2021-03-31)
For a 'permanent' solution, the answer by Rubén Fernández-Casal should work well.
You can force RStudio to show plots in the Source window if you use R Markdown. In a Rmd file, plots are shown together with code; it's called an R Markdown notebook. You can set the size of the plots too, in what is called an R code chunk:
```{r fig.height = 2, fig.width = 3}
plot(mpg ~ wt, mtcars)
```
When you run the chunk, the plot is shown below it.
If you want to set the plot size for the whole notebook, set the package option using opts_knit and opts_chunk, for example:
```{r setup}
library(knitr)
opts_knit$set(global.par = TRUE)
opts_chunk$set(fig.width = 4.5, fig.height = 3.5)
```
For more information, see here and here.
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.
i'm trying to download a file that's 1.1 gigabytes with httr but i'm hitting the following error:
x <- GET( extract.path )
Error in curlPerform(curl = handle$handle, .opts = curl_opts$values) :
cannot allocate more space: 1728053248 bytes
my C drive has 400GB free..
in the RCurl package, i see the maxfilesize and maxfilesize.large options when using getCurlOptionsConstants() but i don't understand if/how these might be passed to httr through config or set_config.. or if i need to switch over to RCurl for this.. and even if i do need to switch, will increasing the maximum filesize work?
here's my sessionInfo..
> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] XML_3.96-1.1 httr_0.2
loaded via a namespace (and not attached):
[1] digest_0.6.0 RCurl_1.95-4.1 stringr_0.6.2 tools_3.0.0
..and (this is not recommended, just because it will take you a while) if you want to reproduce my error, you can go to https://usa.ipums.org/usa-action/samples, register for a new account, choose the 2011 5-year acs extract, add about a hundred variables, and then wait for the extract to be ready. then edit the first three lines and run the code below. (again, not recommended)
your.email <- "email#address.com"
your.password <- "password"
extract.path <- "https://usa.ipums.org/usa-action/downloads/extract_files/some_file.csv.gz"
require(httr)
values <-
list(
"login[email]" = your.email ,
"login[password]" = your.password ,
"login[is_for_login]" = 1
)
POST( "https://usa.ipums.org/usa-action/users/validate_login" , body = values )
GET( "https://usa.ipums.org/usa-action/extract_requests/download" , query = values )
# this line breaks
x <- GET( extract.path )
FYI - this has been added in the write_disk() control in httr:
https://github.com/hadley/httr/blob/master/man/write_disk.Rd
GET calls httr:::make_request this sets the curl options defined in config = list(). However it appears the writefunction otpion is hard coded in 'httr'
opts$writefunction <- getNativeSymbolInfo("R_curl_write_binary_data")$address
You will probably need to use RCurl and define an appropriate `writefunction'. The following
solution Create a C-level file handle in RCurl for writing downloaded files from #Martin Morgan appears to be the way to go.
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.