Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with setwd in R

Tags:

r

When trying to use the sample code for SubgraphMining (the example is on 35th page), I get an error:

"Error in setwd(paste(Sys.getenv("R_HOME"), "library", "subgraphMining",  : 
  cannot change working directory"

I'm using RStudio 0.97.551, 32-bit R (2.15.3 - this version of R was recommended to use with subgraphMining), igraph0 (was recommeded too, instead of igraph library), Java installed. Operation system is Windows 8. Can anyone help me with the issue?

like image 974
Illya K Avatar asked Nov 07 '13 07:11

Illya K


2 Answers

The error message is coming from the gspan function of subgraphMining, from here:

setwd(paste(Sys.getenv("R_HOME"), "library", "subgraphMining", 
    "parsemis", sep = "\\"))

The reason for it is that R uses / as path separator, and not \\, which only works on windows. A workaround is not modify the function and use / instead of \\.

Btw. this has nothing to do with the igraph package, so I'll remove that tag.

like image 56
Gabor Csardi Avatar answered Oct 06 '22 11:10

Gabor Csardi


In my case, it displayed the error because I expected it to create a new folder which I mentioned in the path in setwd. Unfortunately, R does not have this functionality and the matter was resolved when I created the folder and then used setwd command.

like image 45
optimist Avatar answered Oct 06 '22 11:10

optimist