haghish / rcall

Seamless interactive R in Stata. rcall allows communicating data sets, matrices, variables, and scalars between Stata and R conveniently
http://www.haghish.com/packages/Rcall.php
91 stars 29 forks source link

Error when installing in Linux #10

Closed luispfonseca closed 5 years ago

luispfonseca commented 5 years ago

I get an error when installing the package. My machine is running Ubuntu 18.04.2. No issues when installing in a windows machine. Vanilla version of rcall seems to work fine, but default mode resurfaces the error again, even if it prints test output. Do you know what this might be?

Thank you for the package. I've used it to call R packages and it is extremely useful.

. gitget rcall

Installing rcall ...

 --------------------------------------------------------------------------------
  Repository    Username    Install  Description 
 --------------------------------------------------------------------------------
  rcall         haghish     Install  Seamless interactive R in Stata. rcall
                            1137k    allows communicating data sets, matrices,
                                     variables, and scalars between Stata and R
                                     conveniently
                                     homepage http://www.haghish.com/packa~p
                                     updated on 2018-12-17
                                     Hits:944  Stars:20  Lang:Stata  (dependency)

 --------------------------------------------------------------------------------

checking rcall consistency and verifying not already installed...
installing into /home/luis/ado/plus/...
installation complete.

Checking package dependencies
-----------------------------
installing rcall package dependencies:

. /***
> Installing package dependency
> =============================
> 
> The following R packages are required by rcall. rcall attempts to detect R 
> Statistical Software on your system automatically and install the dependency 
> R packages. If the installation fails, read the rcall help file and install 
> the dependencies manually.
> ***/
. 
. rcall_check
Warning messages:
1: In rm(i, pkg, pkglist, major, minor) : object 'i' not found
2: In rm(i, pkg, pkglist, major, minor) : object 'pkg' not found
3: In rm(i, pkg, pkglist, major, minor) : object 'pkglist' not found

. rcall: install.packages("readstata13", repos="http://cran.us.r-project.org")
Installing package into ‘/home/luis/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/src/contrib/readstata13_0.9.2.tar.gz'
Content type 'application/x-gzip' length 61394 bytes (59 KB)
==================================================
downloaded 59 KB

During startup - Warning message:
Setting LC_MESSAGES failed, using "C" 
* installing *source* package ‘readstata13’ ...
** package ‘readstata13’ successfully unpacked and MD5 sums checked
** libs
installing to /home/luis/R/x86_64-pc-linux-gnu-library/3.4/readstata13/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (readstata13)

The downloaded source packages are in
        ‘/tmp/RtmpCbHJIl/downloaded_packages’
Error in if (substr(packageList[i], 1, 8) == "package:") { : 
  missing value where TRUE/FALSE needed
Calls: stata.output
Execution halted
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c read.cpp -o read.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c read_data.cpp -o read_data.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c read_dta.cpp -o read_dta.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c read_pre13_dta.cpp -o read_pre13_dta.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c save_dta.cpp -o save_dta.o
g++  -I/usr/share/R/include -DNDEBUG -I../inst/include -I. -I"/home/luis/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wda
> te-time -D_FORTIFY_SOURCE=2 -g  -c save_pre13_dta.cpp -o save_pre13_dta.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o readstata13.so RcppExports.o read.o read_data.o read_dta.o read_pre13_dta.o save_dta.o save_pre13_dta.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
During startup - Warning message:
Setting LC_MESSAGES failed, using "C" 

. 
end of do-file

. rcall vanilla: print("a")
[1] "a"

. rcall: print("a")
Error in if (substr(packageList[i], 1, 8) == "package:") { : 
  missing value where TRUE/FALSE needed
Calls: stata.output
Execution halted
[1] "a"
haghish commented 5 years ago

if the vanilla works fine, then it is likely that you had used rcall before and have a memory that is loaded when you call R interactively. you can try starting a new R session, typing rcall clear. does that help?

luispfonseca commented 5 years ago

Thank you for getting back. I think the issue remains:

. rcall vanilla: print("a")
[1] "a"

  rcall: print("a")
Error in if (substr(packageList[i], 1, 8) == "package:") { : 
  missing value where TRUE/FALSE needed
Calls: stata.output
Execution halted
[1] "a"

. rcall clear
(R memory cleared)

. rcall: print("a")
Error in if (substr(packageList[i], 1, 8) == "package:") { : 
  missing value where TRUE/FALSE needed
Calls: stata.output
Execution halted
[1] "a"

I wrote a command called rcallcountrycode to interact with an R package using rcall. Thank you for this.

haghish commented 5 years ago

hhmm,

Could you edit a file named stata.output.r in your PLUS directory?

type: fedit stata.output.r, if you have fedit package installed

You can try replacing https://github.com/haghish/rcall/blob/6758660c85033b9889434ed08b60f2550f0be78a/stata.output.r#L293

with a code paragraph, placed into a logical statement, as shown below:

if (length(packageList) > 0) {
  for (i in 1:length(packageList)) {

    # Attach packages
    if (substr(packageList[i], 1, 8) == "package:") {
      name <- substr(packageList[i], 9, nchar(packageList[i]))
      write(paste("library(", name, ")", sep = ""), file=RProfile, append=TRUE)
    }

    # Attach variables and data
    else {
      name <- packageList[i]
      write(paste("attach(", name, ")", sep = ""), file=RProfile, append=TRUE)
    }
  }
}

This will prevent evaluating the packageList when its length is 0. Maybe that solves the problem? If so, I'll update the code.


PS. I will checkout your package, awesome!

haghish commented 5 years ago

fixed in rcall 2.5.0 version

luispfonseca commented 5 years ago

Sorry for not getting back to you earlier. I confirm this has been fixed. Thank you!