rcaller icon indicating copy to clipboard operation
rcaller copied to clipboard

does not import R packages correctly

Open benleblanket opened this issue 7 years ago • 2 comments

I have been trying to use the 'semPlot' package within RCaller's functionality but I am receiving an error that there is no package called 'semPlot', leading to the error that 'semPaths' is an unknown function since 'semPlot' is not imported. I already have the package installed in R and functioning in RStudio. I transferred the code into RCaller to be used. Here is the code I came up with. I happen to be attempting to plot something in this case because that is my ultimate goal but without trying to plot anything, my packages are still not being found:

   `RCode code = RCode.create();

    code.addRCode("x1 <- rnorm(50)");

    code.addRCode("x2 <- rnorm(50)");

    code.addRCode("x3 <- rnorm(50)");

    code.addRCode("x4 <- 2*x1+.3+rnorm(50,sd=.2)");

    code.addRCode("x5 <- 2*x2+.3+rnorm(50,sd=.1)");

    code.addRCode("x6 <- 2*x3+.3+rnorm(50,sd=.3)");

    code.addRCode("data <- data.frame(x1,x2,x3, x4,x5,x6)");

    code.addRCode("data.fact <- factanal(data,3,methods=\"MLE\")");

    File file = code.startPlot();

    System.out.println("Plot will be saved to : " + file);

    code.addRCode("library(semPlot)");

    code.addRCode("semPaths(data.fact, \"est\")");

    code.endPlot();

    rCaller.setRCode(code);

    rCaller.runOnly();

    code.showPlot(file);`

How do you import R packages into RCaller? Also, if there is any difference in procedure for importing into use with RCaller plots, how does that work?

benleblanket avatar Aug 03 '17 16:08 benleblanket

did you try this? code.addRCode("require('packagename')");

Yes I did try using that code right before the library call, right after the library call, and right before the startPlot (if the placement even mattered beyond placing it before the semPaths() call

benleblanket avatar Aug 04 '17 13:08 benleblanket

@benleblanket any improvements for this?

jbytecode avatar Sep 15 '20 19:09 jbytecode