Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haghish committed Sep 20, 2021
1 parent b32ba66 commit 10ceed4
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 24 deletions.
13 changes: 10 additions & 3 deletions R.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// documentation written for markdoc

/***
[Version: 3.0.5](https://github.com/haghish/rcall/tags)
[Version: 3.1.0](https://github.com/haghish/rcall/tags)
cite: [Haghish, E. F. (2019). Seamless interactive language interfacing between R and Stata. The Stata Journal, 19(1), 61-82.](https://journals.sagepub.com/doi/full/10.1177/1536867X19830891)
Expand Down Expand Up @@ -416,8 +416,13 @@ program define R , rclass

// drop the macros
// -------------------------------------------------------------------------

macro drop RcallError

// check the working directory permission
// --------------------------------------
if missing("$wdpermissions") {
wdpermissions
}

// -------------------------------------------------------------------------
// Search R path, if not specified
Expand Down Expand Up @@ -540,6 +545,7 @@ program define R , rclass
// clear the rcall global memory that is used for data transfer
macro drop rcallglobal*
macro drop rcall_synchronize_mode
macro drop wdpermissions

display as txt "(R memory cleared)"
exit
Expand Down Expand Up @@ -764,6 +770,7 @@ program define R , rclass
local 0 : subinstr local 0 ":" ""
}
}


// -------------------------------------------------------------------------
// Execute interactive mode (including sync)
Expand Down Expand Up @@ -1118,7 +1125,7 @@ program define R , rclass
}

if !missing("`vanilla'") file write `knot' "rm(list=ls())" _n // erase memory temporarily
if !missing("`foreign'") file write `knot' "library(readstata13)" _n // load the readstata13 package
if !missing("`foreign'") file write `knot' "suppressWarnings(library(readstata13))" _n // load the readstata13 package
if !missing("`RSite'") & missing("`vanilla'") ///
file write `knot' "source('`RSite'')" _n
if !missing("`rprofile'") & missing("`vanilla'") ///
Expand Down
7 changes: 7 additions & 0 deletions dependency.do
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ R packages. If the installation fails, read the rcall help file and install
the dependencies manually.
***/

// check github version and require minimum of version 2.3.0
quietly github version github
if "`r(version)'" < "2.2.0" {
di as err "please update your GitHub package"
di as txt "type: github update github"
}

rcall_check
rcall: install.packages("readstata13", repos="http://cran.us.r-project.org")
20 changes: 9 additions & 11 deletions examples/Article Examples/rplot.ado
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

// summary program
// ===============
//
// carring the "summary" function in R to summarize data in Stata
// Using the qplot R function in Stata
// ===================================

*cap prog drop rplot
program rplot
version 12
syntax varlist [, colour(name) shape(name) format(name)]
version 14
syntax varlist [, filename(name) colour(name) shape(name) format(name)]

// check for the required packages and versions
// -------------------------------------------------------------------------
rcall_check ggplot2>=2.1.0 , r(3.1.0) rcall(1.3.3)
rcall_check ggplot2>=2.1.0 , r(3.1.0) rcall(2.5.0)

// Checking the variables
// -------------------------------------------------------------------------
Expand All @@ -37,12 +34,13 @@ program rplot
local colour ", colour = `colour'"
}
if !missing("`shape'") local shape ", shape = `shape'"
if missing("`filename'") local filename Rplot
if missing("`format'") local format pdf

rcall vanilla : `format'("Rplot.`format'"); library(ggplot2); ///
qplot(data=st.data(), x =`2', y =`1' `colour' `shape')
rcall vanilla : `format'("`filename'.`format'"); library(ggplot2); ///
qplot(data=st.data(), x =`2', y =`1' `colour' `shape')

di as txt "({browse Rplot.`format'} was produced)"
end

*qplot price mpg , colour(foreign) shape(foreign) format(pdf)
*rplot price mpg , filename(graph) colour(foreign) shape(foreign) format(png)
11 changes: 8 additions & 3 deletions examples/Article Examples/summary.ado
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// summary program
// ===============
//
// carring the "summary" function in R to summarize data in Stata
// Using the "summary" function in R to summarize data in Stata

program summary, byable(recall)
version 12
syntax varlist [if] [in]
marksample touse

rcall_check , rversion(3.0) rcall(2.5.0) //required rcall version and R version

preserve
quietly keep if `touse'
quietly keep `varlist'
Expand All @@ -17,8 +20,10 @@ end

// Examples
/*
by foreign: summary price mpg
summary price mpg if price < 4500
sysuse auto, clear
by foreign: summary price mpg if price < 4500
summary mpg weight if foreign==1
summary price mpg if mpg>25 & mpg<30
summary price mpg in 1/20
*/

5 changes: 5 additions & 0 deletions examples/script/rscriptexample.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This is a regular R script file
print(dim(df))
correlation = cor(df$price, df$mpg)
mat2 = mat^2
print(mat2)
2 changes: 1 addition & 1 deletion make.do
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// DO NOT FORGET to update the version of the package, if changed!
// for more information visit http://github.com/haghish/github

make rcall, replace toc pkg version(3.0.5) ///
make rcall, replace toc pkg version(3.1.0) ///
license("MIT") ///
author("E. F. Haghish") ///
email("[email protected]") ///
Expand Down
11 changes: 9 additions & 2 deletions rcall.ado
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// documentation written for markdoc

/***
[Version: 3.0.6](https://github.com/haghish/rcall/tags)
[Version: 3.1.0](https://github.com/haghish/rcall/tags)
cite: [Haghish, E. F. (2019). Seamless interactive language interfacing between R and Stata. The Stata Journal, 19(1), 61-82.](https://journals.sagepub.com/doi/full/10.1177/1536867X19830891)
Expand Down Expand Up @@ -416,8 +416,13 @@ program define rcall , rclass

// drop the macros
// -------------------------------------------------------------------------

macro drop RcallError

// check the working directory permission
// --------------------------------------
if missing("$wdpermissions") {
wdpermissions
}

// -------------------------------------------------------------------------
// Search R path, if not specified
Expand Down Expand Up @@ -540,6 +545,7 @@ program define rcall , rclass
// clear the rcall global memory that is used for data transfer
macro drop rcallglobal*
macro drop rcall_synchronize_mode
macro drop wdpermissions

display as txt "(R memory cleared)"
exit
Expand Down Expand Up @@ -764,6 +770,7 @@ program define rcall , rclass
local 0 : subinstr local 0 ":" ""
}
}


// -------------------------------------------------------------------------
// Execute interactive mode (including sync)
Expand Down
4 changes: 2 additions & 2 deletions rcall.pkg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
v 3.0.6
v 3.1.0
d 'RCALL': seamless R in Stata
d
d call R in Stata and enable automated data communication
d
d Distribution-Date: 20210810
d Distribution-Date: 20210920
d License: MIT
d
F R.ado
Expand Down
2 changes: 1 addition & 1 deletion rcall.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{browse "https://github.com/haghish/rcall/tags":Version: 3.0.6}
{browse "https://github.com/haghish/rcall/tags":Version: 3.1.0}

{p 4 4 2}
cite: {browse "https://journals.sagepub.com/doi/full/10.1177/1536867X19830891":Haghish, E. F. (2019). Seamless interactive language interfacing between R and Stata. The Stata Journal, 19(1), 61-82.}
Expand Down
2 changes: 1 addition & 1 deletion stata.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v 3.0.6
v 3.1.0
d Materials by E. F. Haghish
d [email protected]
d http://github.com/haghish
Expand Down

0 comments on commit 10ceed4

Please sign in to comment.