cspade failing in RStudio under Windows 10 (but not in Rterm or RStudio under Linux)

In the following code I run the arulesSequences::cspade() function from RStudio (with and without administrator privileges) on a Windows 10 OS. In both cases it fails with the error below.

It works from Rterm (with admin privileges) and also from RStudio under Ubuntu. However, I need to get it working in RStudio under Windows 10...

# install.packages("arulesSequences")
library(arulesSequences)
#> Loading required package: arules
#> Loading required package: Matrix
#> 
#> Attaching package: 'arules'
#> The following objects are masked from 'package:base':
#> 
#>     abbreviate, write
load(system.file("data", "zaki.rda", package = "arulesSequences", lib.loc = .libPaths()))

cspade(zaki, parameter = list(support = 0.1), control = list(verbose = TRUE))
#> 
#> parameter specification:
#> support : 0.1
#> maxsize :  10
#> maxlen  :  10
#> 
#> algorithmic control:
#> bfstype  : FALSE
#> verbose  :  TRUE
#> summary  : FALSE
#> tidLists : FALSE
#> 
#> preprocessing ... 1 partition(s), 0 MB [0.06s]
#> mining transactions ... 0.11 MB [0.06s]
#> reading sequences ... [0.53s]
#> 
#> total elapsed time: 0.65s
#> set of 3917 sequences

Created on 2019-02-14 by the reprex package (v0.2.1)

Any help regarding solutions, workarounds or other hints is very much appreciated!

PS: I might be able to get further admin support from my company to fix issues regarding permissions. However, they are not experienced in R. So any hints regarding possible permission issues would also be helpful.

PPS: Not sure if this is a general, an IDE or an Admin question. Pls. feel free to move this appropriately.

We are not seen any error messages, what is your expected result?

Could you please turn this into a self-contained REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

Thanks @andresrcs. This is very strange.

Please note, that the above is a valid reproducbile example created with the reprex package and indeed, the reprex doesn't show the error message.

However, when I run (or source) the following (same) code in a fresh RStudio session:

# install.packages("arulesSequences")
library(arulesSequences)
#> Loading required package: arules
#> Loading required package: Matrix
#> 
#> Attaching package: 'arules'
#> The following objects are masked from 'package:base':
#> 
#>     abbreviate, write
load(system.file("data", "zaki.rda", package = "arulesSequences", lib.loc = .libPaths()))

cspade(zaki, parameter = list(support = 0.1), control = list(verbose = TRUE))

... I am always getting the error below (last lines of the output shown)

3 4 -> 2 -> 1 -> 1 -- 1 1 
4 -> 1 2 -> 1 -> 1 -- 1 1 
3 -> 1 2 -> 1 -> 1 -- 1 1 
3 4 -> 1 2 -> 1 -> 1 -- 1 1 
3 4 -> 1 -> 1 -> 1 -- 1 1 
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'C:\Users\MGO\AppData\Local\Temp\RtmpcrGqLe\cspadedb066d3533d.out': No such file or directory

As the error doesn't appear when using the reprex-pkg, I tried to investigate further.

As the reprex-pkg uses rmarkdown::render(), I tried to do the same as a workaround, but got the error again. Error message:

Quitting from lines 3-8 (test.spin.Rmd) 
Error in file(con, "r") : cannot open the connection

The only further difference I could think of is the working directory when invoking reprex::reprex().

It seems to turn out, that it works via reprex(), since reprex() runs it's code directly via RTerm, as can be seen under Session info, in the rendered output when si = TRUE in the reprex() call.

So I think one brute force solution would be to write a function which wraps reprex::reprex(), which then just sources the main work (read a .RDS file, run cspade(), write a .RDS file).

However, this doesn't seem elegant and heavily dependent on reprex and possibly further environment settings. So, ideally someone could point me to a way to source an RScript via RTerm, but from within RStudio.

Ok, think I got it. Full solution now.

  1. Write a short R script (test.R), which reads the data from disk, executes cspade() and writes the result to disk (possibly wrap this script appropriately into another function to clean the files afterwards). For testing this script should suffice

    library(arulesSequences)
    load(system.file("data", "zaki.rda", package = "arulesSequences", lib.loc = .libPaths()))
    
    df2 <- cspade(zaki, parameter = list(support = 0.1), control = list(verbose = TRUE))
    saveRDS(df2, "C:/R/Projects/sequential_pattern_mining/df_save.RDS")
    
  2. Run the script in Rscript.exe (this could be better than using RTerm.exe, see, i.e. here). This can be achieved from RStudio via the system2() function:

    system2(command = "C:/Program Files/R/R-3.5.2/bin/x64/Rscript.exe",
            args = "C:/R/Projects/sequential_pattern_mining/R/test.r")
    

Paths for Rscript.exe and the working directory (to save files) need to be set individually, of course.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.