R Studio Crashes when Crosstable function runs - r

I'm having an issue with R Studio crashing when I run the Crosstable function. First, I'm installing the following packages:
install.packages ("gmodels"); install.packages("MASS")
library (gmodels); library (MASS)
Then, I run the following code on my data frame:
CrossTable(dat$PopSize, dat$PCIncChange, fisher = TRUE, chisq = TRUE)
expected = TRUE, sresid = TRUE, format="SPSS")
R produces the table, but then does not allow me to execute any other code in the console. It also doesn't allow me to save my file or quit the program (I've had to use control alt delete every time).
-- Edit: Adding session info from comments --
sessionInfo():
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
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] splines stats graphics grDevices utils datasets methods base –
other attached packages: [1] MASS_7.3-23 gmodels_2.15.3 Hmisc_3.10-1 survival_2.36-14 stringr_0.6.2
loaded via a namespace (and not attached): [1] cluster_1.14.3 gdata_2.12.0 grid_2.15.2 gtools_2.7.0 lattice_0.20-10 tools_2.15.2
Any ideas?

Related

Difference between R tm package stemDocument function behavior and original Porter stemming algorithm

Using R's stemDocument function from the tm package (see session info below) I get:
library(tm)
stemDocument("cmos")
[1] "cmos"
However when using this implementation in Java and when using this "online Porter stemmer" the result of stemming "cmos" would be: "cmo".
Also in the original article the Step 1a rule says:
Step 1a
SSES -> SS caresses -> caress
IES -> I ponies -> poni
ties -> ti
SS -> SS caress -> caress
S -> cats -> cat
Meaning that a string "cmos" ending with "s" should be stemmed to "cmo", deleting the "s".
So why is R's stemDocument function behavior different?
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tm_0.6 NLP_0.1-5
loaded via a namespace (and not attached):
[1] parallel_3.1.2 slam_0.1-32 SnowballC_0.5.1 tools_3.1.2

Newest raster package won't plot a raster object in Windows

I'm trying to plot a raster using the "raster" package but I'm running against an error
Here's my code
map = raster("A055E.tif")
plot(map)
Error in `colnames<-`(`*tmp*`, value = "A055E") :
length of 'dimnames' [2] not equal to array extent
sessionInfo()
R version 3.1.1 (2014-07-10)
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
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.9-1 raster_2.3-0 sp_1.0-15
loaded via a namespace (and not attached):
[1] grid_3.1.1 lattice_0.20-29 tools_3.1.1
However, when I run it on a linux machine with the following versions:
R version 3.1.1 (2014-07-10)
Platform: i686-pc-linux-gnu (32-bit),
raster_2.2-31 sp_1.0-15)
it doesn't give me an issue
I think that if you update the raster package things will work again.
On windows computer I had similar problem - I couldn't plot 3-band raster map using plotRGB(). The solution was to handly remove package 'raster' and just install it again.

Using quit/q in a function causes RStudio to fatal error

More of a curiosity but when you use q or quit inside of a function inside of R studio it causes a fatal error as seen here:
But the same function in rgui causes R to stop as usual. And using just q() in RStudio closes R as expected. Why does q in a function cause RStudio to literally bomb? Is this a local issue? Can others replicate it?
Example function that causes the bomb:
FUN <- function() q()
FUN()
Here's my sessionInfo:
R Under development (unstable) (2013-09-04 r63830)
Platform: i386-w64-mingw32/i386 (32-bit)
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
loaded via a namespace (and not attached):
[1] tools_3.1.0
RStudio Version 0.97.551

accessing global environment objects created in cached chunks Rmarkdown documents

I want to run a R script to run a simulation and cache the results for the Rmarkdown document. I am using Rstudio and try to create an HTML report by using knit HTML Here's a simple example.
```{r test_global_env,cache=TRUE}
print(getwd())
source("./test_script.R")
```
```{r test_global_env_2}
print(a)
```
and test_script.R is as follows
a<-1
When I change the cache option for the chunk to FALSE, print(a) works. If I set it to TRUE, it works the first time, the second time, I get object 'a' not found error.
A similar question is Can knit2pdf use the global environment? , but I could not figure out if it applies to my situation. Here is the sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
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 datasets
[6] methods base
other attached packages:
[1] knitr_1.2 igraph_0.6.5-2 lubridate_1.3.0
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 formatR_0.8
[4] memoise_0.1 plyr_1.8 stringr_0.6.2
[7] tools_3.0.0

R.matlab package appears corrupted

Solution: The package R.oo used by R.matlab has a function called getDate. I was loading --another function getDate() before loading the R.matlab package.
I can't load the R package R.matlab
Anyone has the same issue? I have the following error message:
Loading required package: R.matlab
Error in as.POSIXlt.POSIXct(x, tz) : invalid 'tz' value
Error: package 'R.matlab' could not be loaded
Edit: it happens since the last update on 3rd of Feb 2011
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-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] grDevices datasets splines graphics stats tcltk utils methods base
other attached packages: [1] R.oo_1.7.5 R.methodsS3_1.2.1 waveslim_1.6.4 timeDate_2130.91 ncdf_1.6.5 rgl_0.92.798
[7] fields_6.3 spam_0.23-0 splancs_2.01-27 sp_0.9-76 maps_2.1-5 shapefiles_0.6
[13] foreign_0.8-41 scrapeR_0.1.6 XML_3.2-0.2 mFilter_0.1-3 RCurl_1.5-0.1 bitops_1.0-4.1
[19] outliers_0.14 chron_2.3-39 lmtest_0.9-27 PerformanceAnalytics_1.0.3.2 RODBC_1.3-2 quantmod_0.3-15
[25] TTR_0.20-2 xts_0.7-5 zoo_1.6-4 Defaults_1.1-1 rcom_2.2-3.1 rscproxy_1.3-1
[31] svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 Hmisc_3.8-3 survival_2.36-2
loaded via a namespace (and not attached):
[1] cluster_1.13.2 grid_2.12.1 lattice_0.19-17 svMisc_0.9-61 tools_2.12.1
That's not an issue with R.matlab, but with something else. I see that it says "loading required package: R.matlab" , so the command came from somewhere else.
> library(R.matlab)
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.7.5 (2011-02-01) successfully loaded. See ?R.oo for help.
R.matlab v1.3.7 (2011-02-01) successfully loaded. See ?R.matlab for help.
On Windows 7, R 2.12.1.
Please provide the full detail of the command you used that loaded R.matlab. And you might want to post this on the R-help list or R-devel list, this seems to be a bug of some kind. It's always a good idea to put the package maintainer in cc, so they know.
Session info :
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] grid grDevices datasets splines graphics stats tcltk utils methods base
other attached packages:
[1] R.matlab_1.3.7 R.oo_1.7.5 R.methodsS3_1.2.1 reshape_0.8.3 plyr_1.2.1 gplots_2.8.0
[7] caTools_1.11 bitops_1.0-4.1 gdata_2.8.1 gtools_2.6.2 RColorBrewer_1.0-2 chron_2.3-39
[13] xlsReadWrite_1.5.3 svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 Hmisc_3.8-3 survival_2.36-2
loaded via a namespace (and not attached):
[1] cluster_1.13.2 lattice_0.19-13 svMisc_0.9-61 tools_2.12.1
Solution: The package R.oo used by R.matlab has a function called getDate. I was loading --another function getDate() before loading the R.matlab package.

Resources