Mark Kimpel
2011-May-17 02:50 UTC
[Rd] R crashes if "toFile" given "~/" in Linux envirnonment
I was running some sample code from a help page tonight and wished to redirect the sample output to my Desktop under Linux (Mint-Debian 64 if it makes a different). I was surprised to find that file name expansion using the ubuquitious "~/" was not recognized, in fact it caused R to crash. Is this expected behavior? See my output below and sessionInfo(). Also, not shown, but 'setwd("~/Desktop")' works just fine. Thanks, Mark # sample code from Rgraphviz clusterData help page library(graph) library(Rgraphviz) g1_gz <- gzfile(system.file("GXL/graphExample-01.gxl.gz",package="graph"), open="rb") g11_gz <- gzfile(system.file("GXL/graphExample-11.gxl.gz",package="graph"), open="rb") g1 <- fromGXL(g1_gz) g11 <- fromGXL(g11_gz) g1_11 <- join(g1, g11) sgl <- vector(mode="list", length=2) sgl[[1]] <- list(graph=g1, cluster=TRUE) sgl[[2]] <- list(graph=g11, cluster=TRUE) ng <- agopenSimple(g1_11, "tmpsg", subGList=sgl) clusterData(ng, 1, c("bgcolor")) <- c("blue") clusterData(ng, 2, c("bgcolor")) <- c("red") ############################################ # and now 2 usually equivalent ways to specify the location for output file, with the second way crashing: toFile(ng, layoutType="dot", filename="/home/mkimpel/Desktop/g1_11_dot.ps", fileType="ps") NULL toFile(ng, layoutType="dot", filename="~/Desktop/g1_11_dot.ps", fileType="ps") ~/Desktop/g1_11_dot.ps: No such file or directory Process R exited abnormally with code 1 at Mon May 16 22:42:12 2011 ################################################# # and my sessionInfo() R version 2.13.0 (2011-04-13) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 LC_MONETARY=C [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] stats graphics grDevices datasets utils methods base #################################################### Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 399-1219 Skype No Voicemail please [[alternative HTML version deleted]]
Simon Urbanek
2011-May-17 03:02 UTC
[Rd] R crashes if "toFile" given "~/" in Linux envirnonment
Mark, I think you have the wrong list - this has nothing to do with R. to File() is a function in Rgraphviz and it doesn't crash, it simply exits R. Obviously it doesn't support path expansion (I suppose it should consider calling path.expand()) and it should also consider using R_error() instead of quitting -- but both issues should be best addressed to the Rgraphviz maintainers. Cheers, Simon On May 16, 2011, at 10:50 PM, Mark Kimpel wrote:> I was running some sample code from a help page tonight and wished to > redirect the sample output to my Desktop under Linux (Mint-Debian 64 if it > makes a different). I was surprised to find that file name expansion using > the ubuquitious "~/" was not recognized, in fact it caused R to crash. Is > this expected behavior? See my output below and sessionInfo(). Also, not > shown, but 'setwd("~/Desktop")' works just fine. Thanks, Mark > > # sample code from Rgraphviz clusterData help page > library(graph) > library(Rgraphviz) > g1_gz <- gzfile(system.file("GXL/graphExample-01.gxl.gz",package="graph"), > open="rb") > g11_gz <- gzfile(system.file("GXL/graphExample-11.gxl.gz",package="graph"), > open="rb") > g1 <- fromGXL(g1_gz) > g11 <- fromGXL(g11_gz) > g1_11 <- join(g1, g11) > sgl <- vector(mode="list", length=2) > sgl[[1]] <- list(graph=g1, cluster=TRUE) > sgl[[2]] <- list(graph=g11, cluster=TRUE) > ng <- agopenSimple(g1_11, "tmpsg", subGList=sgl) > clusterData(ng, 1, c("bgcolor")) <- c("blue") > clusterData(ng, 2, c("bgcolor")) <- c("red") > ############################################ > # and now 2 usually equivalent ways to specify the location for output file, > with the second way crashing: > toFile(ng, layoutType="dot", filename="/home/mkimpel/Desktop/g1_11_dot.ps", > fileType="ps") > NULL > toFile(ng, layoutType="dot", filename="~/Desktop/g1_11_dot.ps", > fileType="ps") > ~/Desktop/g1_11_dot.ps: No such file or directory > > Process R exited abnormally with code 1 at Mon May 16 22:42:12 2011 > ################################################# > # and my sessionInfo() > R version 2.13.0 (2011-04-13) > Platform: x86_64-unknown-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C > LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 LC_MONETARY=C > > [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] stats graphics grDevices datasets utils methods base > #################################################### > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry > Indiana University School of Medicine > > 15032 Hunter Court, Westfield, IN 46074 > > (317) 490-5129 Work, & Mobile & VoiceMail > (317) 399-1219 Skype No Voicemail please > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >