R `dev.new()` freezes - r

this just started to occur: when I type the command dev.new(), the window stays frozen, and I can't Ctrl+c to stop it. I have to kill the R process in another terminal. I am running 64-bit CentOS 6.7 and R 3.2.1. Here is the output from sessionInfo():
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS release 6.7 (Final)
locale:
[1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 LC_MONETARY=en_US.utf8
[6] LC_MESSAGES=en_US.utf8 LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] graphics grDevices utils datasets stats methods base
other attached packages:
[1] ggplot2_1.0.1 data.table_1.9.4 plyr_1.8.3 reshape2_1.4.1 vimcom_0.9-9 setwidth_1.0-4 colorout_1.1-0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.0 digest_0.6.8 MASS_7.3-44 chron_2.3-47 grid_3.2.1 gtable_0.1.2 magrittr_1.5 scales_0.3.0
[9] stringi_0.5-5 proto_0.3-10 tools_3.2.1 stringr_1.0.0 munsell_0.4.2 colorspace_1.2-6
Has anybody come across this issue? Perhaps of relevance, but I was able to use a GUI application that creates plot devices as a cairoDevice, with no issues.
EDIT: A bit more info - when running R --vanilla, the same behavior occurs. Same with calling plot directly (e.g. plot(rnorm(1e2))), and making a call to ggplot.
EDIT 2: in case this wasn't confusing enough, I am able to plot without issue on my home system (where sessionInfo gives the same output, aside from some packages loaded via a namespace). I believe the same CentOS packages are installed, as well.
EDIT 3: to add a bit more info, in addition to the (RGtk2) GUI that I mentioned still works, I can call Cairo from the command line directly and plotting works without issue that way. So it seems to be specific to base plotting.

I had the same problem on SL6.7. This is not a R problem but rather the xorg-x11-server-Xorg update crashed it.
Just downgrade the package and restart your X-session and you can plot again.
~$ yum downgrade http://ftp.scientificlinux.org/linux/scientific/6.6/x86_64/updates/security/xorg-x11-server-Xorg-1.15.0-26.sl6.x86_64.rpm
To make it permanent disable the upgrade of the package in yum.conf
~$ echo "exclude=xorg-x11-server-Xorg" >> /etc/yum.conf

Actually, the issue with R was not really a bug in xorg-x11-server.
Its update (Fix backing store's Always mode) revealed a bug in the X11
module of R. More details can be found in R's bugzilla :
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16497
(See comment 5 for details)
A couple of patches to fix the issue have been proposed.

Related

BigRquery will not connect and the error message is blank

I'm trying to make use of the 'bigrquery' library in R to connect R to our big query databases. When I run this on a locally installed copy of R studio I don't have any problems, but when I'm running it on a server running R Studio Server I get a strange error message from the query_exec command. I will paste the code below:
library(bigrquery)
project = 'projectIdentifier'
sql <- "SELECT * FROM [bradWorking.bradTempTable] WHERE f0_ >= '2015-10-22' AND f0_ <= '2015-11-01'"
data <- query_exec(query = sql, project=project, max_pages = Inf, destination_table = 'bradWorking.bradTempTable2')
Error:
I have never seen an error before that simply states 'Error'. Does anyone have any suggestions for ways to figure out what's going on? Could this be related to the libssl that I'm using?
Here's the system information from R
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] bigrquery_0.1.0
loaded via a namespace (and not attached):
[1] httr_1.1.0 magrittr_1.5 R6_2.1.2
[4] assertthat_0.1 parallel_3.2.3 DBI_0.3.1
[7] tools_3.2.3 dplyr_0.4.3 curl_0.9.5
[10] Rcpp_0.12.3 jsonlite_0.9.19 openssl_0.9.1
Thanks
I am not very familiar with bigrquery, but it looks like this could be an incompatibility between bigrquery and httr 1.1.0: https://github.com/rstats-db/bigrquery/issues/86
rolling back httr as per https://github.com/rstats-db/bigrquery/issues/86 worked for me when i experienced this error.
Not sure if this is useful but I'm getting the same error on a query of mine that's been running perfectly for the past couple months. Not sure if the issue is on the Google or R side

Cannot load package in R

Since yesterday, I cannot load some common used packages, e.g. reshape2 and stringr through library command.
Step to reproduce my problem:
1) Start a new session in Rstudio server (Version 0.99.467). I also kill the active-sessions in Rstudio server.
2) Run these codes
library(ggplot2)
library(stringr)
3) Get an error message:
Error in unloadNamespace(package) :
namespace ‘stringr’ is imported by ‘reshape2’ so cannot be unloaded
Show Traceback
Rerun with Debug
Error in library(stringr) : “stringr” version 0.6.2 cannot be unloaded.
But I don't get error if stringr is loaded before ggplot2. How should I fix this problem. Thanks for any suggestions.
I may have to update R to 3.2
My R session info:
R version 3.1.3 (2015-03-09)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
[5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 LC_PAPER=en_AU.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.0
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.4 grid_3.1.3 gtable_0.1.2 MASS_7.3-39 munsell_0.4.2 plyr_1.8.1
[8] proto_0.3-10 Rcpp_0.11.2 reshape2_1.4 scales_0.2.4 stringr_0.6.2 tools_3.1.3
I resolved my problem through updating R and all R packages.
I guess the problem is caused by old version of stringr or reshape2 as I install the same packages in different places (system folder or personal library). R tried to load a old version of package.
Even though it is a good practice to update R for me it was not necessary to solve the same issue. The problem can result from few .libPaths(). With .libPaths("C:/Program Files/R/R-3.4.3patched/library") you can point out one folder. After that just reinstall of packages, and it should work.
My code:
> .libPaths()
[1] "L:/My Documents/R/win-library/3.4" "C:/Program Files/R/R-3.4.3patched/library"
> .libPaths("C:/Program Files/R/R-3.4.3patched/library")
> packages<-c('ggplot2','data.table','knitr','xtable')
> install.packages(packages)
> lapply(packages,library,character.only=T)
Even though the issue is solved I hope it will help someone.

Trouble with packrat corrupting R functioning

I installed the package packrat at some point, used it perhaps once and moved on with my life.
However, despite not having loaded it in months, it remains a nuisance to my regular R usage.
Seemingly at random, my R session within RStudio will fail with errors at certain operations, especially package installation. Here's the most recent error message (after running parallel::makeCluster(parallel::detectCores()):
Error in file(filename, "r", encoding = encoding) : cannot open the
connection
Calls: source -> file
In addition: Warning message:
In
file(filename, "r", encoding = encoding) : cannot open file
'packrat/init.R': No such file or directory
Execution halted
I checked all of the folders on .libPaths() and I don't even have packrat installed anymore. Why on earth is R still trying to carry out packrat operations? And how can I stop this?
My duct-tape solution so far is to simply close and reopen RStudio, which works like a charm for package installation issues.
However, I cannot seem to get around this for makeCluster(detectCores()) within just one .R script I've got. It works perfectly fine in another script for another project.
Background:
sessionInfo()
# R version 3.2.2 (2015-08-14)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Ubuntu 14.04.2 LTS
# locale:
# [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
# [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
# [7] LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8
# [10] LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8
# attached base packages:
# [1] parallel stats graphics grDevices utils datasets methods base
# other attached packages:
# [1] doParallel_1.0.8 iterators_1.0.7 foreach_1.4.2 geosphere_1.4-3 xlsx_0.5.7 xlsxjars_0.6.1
# [7] rJava_0.9-6 xtable_1.7-4 sandwich_2.3-3 texreg_1.35 maptools_0.8-36 sp_1.1-1
# [13] ggmap_2.5.2 ggplot2_1.0.1 data.table_1.9.5
# loaded via a namespace (and not attached):
# [1] Rcpp_0.11.6 plyr_1.8.3 tools_3.2.2 digest_0.6.8 gtable_0.1.2
# [6] lattice_0.20-33 png_0.1-7 mapproj_1.2-4 proto_0.3-10 stringr_1.0.0
# [11] RgoogleMaps_1.2.0.7 maps_2.3-11 grid_3.2.2 jpeg_0.1-8 foreign_0.8-66
# [16] RJSONIO_1.3-0 reshape2_1.4.1 magrittr_1.5 codetools_0.2-11 scales_0.2.5
# [21] MASS_7.3-43 colorspace_1.2-6 stringi_0.5-9003 munsell_0.4.2 chron_2.3-47
# [26] rjson_0.2.15 zoo_1.7-12
Update 1:
Installing packrat had no effect. Running packrat::init() resulted in an error before finishing; nothing changed.
Update 2:
I've isolated the problem by identifying that it's the working directory that's causing the issues. What in the working directory I'm using might be causing the problems? Some residual file from having run packrat previously in this directory?
Through further trial and error given the prods of #BondedDust I finally appear to have solved the issue. Having previously tried to use packrat in the particular working directory in which I was working appears to have left some vestiges despite later uninstalling packrat.
In particular, packrat edits your local .Rprofile (original credit due to #zerweck and #snaut), which is source()d on R startup in that directory.
If you use the .Rprofile to store some local configurations, you should edit the file and remove the packrat lines (or any you don't recognize); otherwise, you should just delete that file to restore your project to working as expected.
Check your HOME directory for an unintentional .Rprofile.
Packrat may have put this here if you tried to packrat::init() in HOME.
install.package() with packrat looks for .Rprofile when run. The behavior I've observed has it prioritizing the HOME .Rprofile over the getwd() one, causing the
cannot open file 'packrat/init.R': No such file or directory

ggplot: object 'DiscreteRange' not found

This is embarrassing. I've been using the ggplot2 package on a regular basis over the past few months, and now suddenly things seem to go seriously wrong.
Apparently, whenever I try to plot a bar graph I obtain the error:
Error in structure(list(call = match.call(), aesthetics = aesthetics, :
object 'DiscreteRange' not found
This is the error that results, e.g., when I try to run a code as simple as the following:
library(ggplot2)
ggplot(diamonds, aes(x=cut)) + geom_bar()
There is no graphics output, the code stops with the above error message.
If I recall correctly this used to work up to a few days ago, so I suspect that there is some error in an (update of) another package that interferes. Of course, I may also be doing a very stupid mistake that I don't see.
I'm using RStudio version 0.99.467; more information concerning the system and the relevant packages is provided below:
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.0 lattice_0.20-33 zoo_1.7-11 digest_0.6.8 MASS_7.3-43 grid_3.2.1 plyr_1.8.3 gtable_0.1.2
[9] magrittr_1.5 scales_0.2.5.9003 stringi_0.5-5 reshape2_1.4.1 proto_0.3-10 blotter_0.9.1666 tools_3.2.1 stringr_1.0.0
[17] munsell_0.4.2 colorspace_1.2-6 quantstrat_0.9.1669
I tried to restart a fresh R session and even rebooted the computer, to no avail.
Thank you very much for your help!
I'm going to take a guess that the problem is with the scales package, which is at version: 0.2.5.9003. The packages with "four-part" version numbers x.y.z.wwww look like development versions to me. The current CRAN version is 0.2.5:
a1 <- available.packages()
a1[a1[,"Package"]=="scales","Version"] ## 0.2.5
I don't know how you ended up with a development version (devtools::install_github("hadley/scales") would probably do it) but I would install.packages("scales") (or the equivalent through the RStudio GUI) to re-install the CRAN version and see if that resolves the problem.
Alternatively, you could try keeping the development version of scales and moving to the development version of ggplot2 (devtools::install_github("hadley/ggplot2")).
I'm using the development version of ggplot2 (1.0.1.9003) with the development version of scales (0.2.5.9003) and your example works fine.

What can I do about frequent, unreproducible segfault errors in R 3.0.1?

After upgrading to R 3.0.X, I've started getting pretty frequent, unreproducible segfault errors like those found by this asker. I never had one of these errors before with R 2.X.X. For example, this is the session info for a long block of code that just caused a fault. However, after R crashed, I ran the entire block of code again and there was no error.
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.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] klaR_0.6-8 ggplot2_0.9.3.1 labdsv_1.5-0 MASS_7.3-26 mgcv_1.7-22
[6] cluster_1.14.4 sparcl_1.0.3 FD_1.0-11 vegan_2.0-7 permute_0.7-0
[11] geometry_0.3-3 magic_1.5-4 abind_1.4-0 ape_3.0-8 ade4_1.5-2
[16] plyr_1.8
loaded via a namespace (and not attached):
[1] class_7.3-7 colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3
[5] e1071_1.6-1 grid_3.0.1 gtable_0.1.2 labeling_0.1
[9] lattice_0.20-15 Matrix_1.0-12 munsell_0.4 nlme_3.1-109
[13] proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3
[17] stringr_0.6.2
Sometimes R freezes completely and I have to do a force quit, but other times, it allows me to exit with options for a core dump or saving the workspace.
Someone in another post suggested setting options(CBoundsCheck=T) and that seemed to work for a while but I am still getting frequent faults.
I don't think these faults are related to any specific kind of calculation or function as I got one the other day after starting a new session and only setting my working directory and options. The code that triggered the fault and the system info would look like this:
#Set my working directory
setwd("~/Documents/School Spring 2013/Quaternary Dissasembly/Functional Diversity Basefile 3")
#Keep getting segfaults all the time. This might fix it
options(CBoundsCheck=T)
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.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
Any help anyone could give me to find and fix the bug or the incorrect settings I have would be greatly appreciated. Thank you.
-M

Resources