Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
smatiweb committed Nov 13, 2023
2 parents fd367bd + 6ee31ce commit d930fc9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 36 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: EviewsR
Type: Package
Title: A Seamless Integration of 'EViews' and R
Version: 0.1.5
Version: 0.1.6
Authors@R: c(
person("Sagiru", "Mati", role = c("aut", "cre"), email = "smati@smati.com.ng",comment=c(ORCID="0000-0003-1413-3974")))
Maintainer: Sagiru Mati <smati@smati.com.ng>
person("Sagiru", "Mati", role = c("aut", "cre"), email = "sagirumati@gmail.com",comment=c(ORCID="0000-0003-1413-3974")))
Maintainer: Sagiru Mati <sagirumati@gmail.com>
Description: It allows running 'EViews'(<https://eviews.com>) program from R, R Markdown and Quarto documents. 'EViews' (Econometric Views) is a statistical software for Econometric analysis. This package integrates 'EViews' and R and also serves as an 'EViews' Knit-Engine for 'knitr' package. Write all your 'EViews' commands in R, R Markdown or Quarto documents.
Depends: R (>= 3.4.0)
Imports: knitr (>= 1.20), magrittr, xts, zoo
Expand All @@ -15,7 +15,7 @@ URL: https://CRAN.R-project.org/package=EviewsR
BugReports: https://github.com/sagirumati/EviewsR/issues
Encoding: UTF-8
VignetteBuilder: knitr
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2022-08-08 15:31:44 UTC; Sagiru
Repository: CRAN
Expand Down
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

What's new?

* `import_graph`function now uses chunk option `graph_procs`, however the chunk option is overwritten by `graph_procs` function argument.
* Bug fixes: `graph_procs` is now working in import_graph function
* `import_graph()` and `eviews_graph()` functions now use chunk option `graph_procs`, if the function argument `graph_procs=""`.

* Bug fixes: `graph_procs` is now working in chunk options

Expand Down
43 changes: 22 additions & 21 deletions R/eng_eviews.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ eng_eviews <- function(options) {

options$eval=options$eval %n% opts_chunk$get("eval")

if(!options$eval) {
options$fig.cap=options$fig.subcap=NULL # Quarto evaluates caption even if eval=F
opts_current$set(fig.cap=NULL,fig.subcap=NULL)
}
# if(!options$eval) {
# options$fig.cap=options$fig.subcap=NULL # Quarto evaluates caption even if eval=F
# opts_current$set(fig.cap=NULL,fig.subcap=NULL)
# }

options$echo=options$echo %n% opts_chunk$get("echo")

Expand Down Expand Up @@ -128,13 +128,13 @@ if(options$eval){
for %page {%pagelist}
pageselect {%page}
if %graph="first" then
if %graph="@first" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wleft(%selectedGraphs,1)
else if %graph="last" then
else if %graph="@last" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wright(%selectedGraphs,1)
else if %graph="asis" or %graph="asc" or %graph="desc" or %figKeep1="numeric" then
else if %graph="@asis" or %graph="@asc" or %graph="@desc" or %figKeep1="numeric" then
%selectedGraphs=@wlookup("*","graph")
else
%selectedGraphs=@wlookup(%graph,"graph")
Expand All @@ -153,9 +153,9 @@ if(options$eval){
{%y}.options size(6,3)
{%y}.options -background frameaxes(all) framewidth(0.5)
{%y}.setelem(1) linecolor(@rgb(57,106,177)) linewidth(1.5)
{%y}.setelem(2) linecolor(@rgb(218,124,48)) linewidth(1.5)
{%y}.setelem(2) linecolor(@rgb(204,37,41)) linewidth(1.5)
{%y}.setelem(3) linecolor(@rgb(62,150,81)) linewidth(1.5)
{%y}.setelem(4) linecolor(@rgb(204,37,41)) linewidth(1.5)
{%y}.setelem(4) linecolor(@rgb(218,124,48)) linewidth(1.5)
{%y}.setelem(5) linecolor(@rgb(83,81,84)) linewidth(1.5)
{%y}.setelem(6) linecolor(@rgb(107,76,154)) linewidth(1.5)
{%y}.setelem(7) linecolor(@rgb(146,36,40)) linewidth(1.5)
Expand Down Expand Up @@ -185,6 +185,7 @@ if(options$eval){
{%y}.setfont legend(Calibri,12,-b,-i,-u,-s) text(Calibri,14,-b,-i,-u,-s) obs(Calibri,14,-b,-i,-u,-s) axis(Calibri,14,-b,-i,-u,-s)
{%y}.setfont obs(Calibri,14,-b,-i,-u,-s)
{%y}.textdefault font(Calibri,14,-b,-i,-u,-s)
{%y}.datelabel format("YYYY")
next
endif
next'
Expand All @@ -200,13 +201,13 @@ if(options$eval){
for %page {%pagelist}
pageselect {%page}
if %graph="first" then
if %graph="@first" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wleft(%selectedGraphs,1)
else if %graph="last" then
else if %graph="@last" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wright(%selectedGraphs,1)
else if %graph="asis" or %graph="asc" or %graph="desc" or %figKeep1="numeric" then
else if %graph="@asis" or %graph="@asc" or %graph="@desc" or %figKeep1="numeric" then
%selectedGraphs=@wlookup("*","graph")
else
%selectedGraphs=@wlookup(%graph,"graph")
Expand Down Expand Up @@ -313,7 +314,7 @@ if(options$eval){
exit'


if(!identical(graph1,'asis')){
if(!identical(graph1,'@asis')){
graphPath='%save_path=@wreplace(%save_path,"* ","*")
%save_path=@wreplace(%save_path,"/","\\")
Expand Down Expand Up @@ -350,13 +351,13 @@ if(options$eval){
pageselect {%page}
if %graph="first" then
if %graph="@first" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wleft(%selectedGraphs,1)
else if %graph="last" then
else if %graph="@last" then
%selectedGraphs=@wlookup("*","graph")
%selectedGraphs=@wright(%selectedGraphs,1)
else if %graph="asis" or %graph="asc" or %graph="desc" or %figKeep1="numeric" then
else if %graph="@asis" or %graph="@asc" or %graph="@desc" or %figKeep1="numeric" then
%selectedGraphs=@wlookup("*","graph")
else
%selectedGraphs=@wlookup(%graph,"graph")
Expand Down Expand Up @@ -385,11 +386,11 @@ if(options$eval){



####### GRAPH="ASIS" #####################
####### GRAPH="@asis" #####################



if(identical(graph1,"asis")) {
if(identical(graph1,"@asis")) {

#### Generate graphPath from the options$code

Expand Down Expand Up @@ -516,10 +517,10 @@ for (i in graphIndex) eviewsCode=append(eviewsCode,appendCode,i)
if(file.exists(paste0(eviewsrText1,"-graph.txt"))){ graphPath=readLines(paste0(eviewsrText1,"-graph.txt")) %>%
strsplit(split=" ") %>% unlist() %>% tolower()

if(any(graph1=="desc")) graphPath %<>% sort(decreasing = TRUE)
if(any(graph1=="asc")) graphPath %<>% sort
if(any(graph1=="@desc")) graphPath %<>% sort(decreasing = TRUE)
if(any(graph1=="@asc")) graphPath %<>% sort
if(is.numeric(graph1)) graphPath=graphPath[graph1]
if(identical(graph1,"asis") && !identical(page1,"*")) graphPath=graphPath[grep(pagePattern,graphPath,ignore.case = TRUE)]
if(identical(graph1,"@asis") && !identical(page1,"*")) graphPath=graphPath[grep(pagePattern,graphPath,ignore.case = TRUE)]

if(is.numeric(graph1)) file.copy(paste0(tempDir1,'/',graphPath,'.',extension),paste0(save_path1,'/',graphPath,'.',extension),overwrite = TRUE)

Expand Down
7 changes: 5 additions & 2 deletions R/eviews_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#' @export
eviews_graph=function(wf="",page="*",series="*",group=FALSE,graph_command="line",graph_options="",mode="overwrite",graph_procs="",datelabel="",save_options='',save_path="",frequency="m",start_date="",save_copy=TRUE){

if(identical(graph_procs,"") && !is.null(opts_current$get('graph_procs'))) graph_procs=opts_current$get('graph_procs')

if(is.xts(series)) series=data.frame(date=index(series),coredata(series))

if(wf!="" && save_path=="") save_path=dirname(wf)
Expand All @@ -65,9 +67,9 @@ if(wf!="" && save_path=="") save_path=dirname(wf)
{%y}.options size(6,3)
{%y}.options -background frameaxes(all) framewidth(0.5)
{%y}.setelem(1) linecolor(@rgb(57,106,177)) linewidth(1.5)
{%y}.setelem(2) linecolor(@rgb(218,124,48)) linewidth(1.5)
{%y}.setelem(2) linecolor(@rgb(204,37,41)) linewidth(1.5)
{%y}.setelem(3) linecolor(@rgb(62,150,81)) linewidth(1.5)
{%y}.setelem(4) linecolor(@rgb(204,37,41)) linewidth(1.5)
{%y}.setelem(4) linecolor(@rgb(218,124,48)) linewidth(1.5)
{%y}.setelem(5) linecolor(@rgb(83,81,84)) linewidth(1.5)
{%y}.setelem(6) linecolor(@rgb(107,76,154)) linewidth(1.5)
{%y}.setelem(7) linecolor(@rgb(146,36,40)) linewidth(1.5)
Expand Down Expand Up @@ -97,6 +99,7 @@ if(wf!="" && save_path=="") save_path=dirname(wf)
{%y}.setfont legend(Calibri,12,-b,-i,-u,-s) text(Calibri,14,-b,-i,-u,-s) obs(Calibri,14,-b,-i,-u,-s) axis(Calibri,14,-b,-i,-u,-s)
{%y}.setfont obs(Calibri,14,-b,-i,-u,-s)
{%y}.textdefault font(Calibri,14,-b,-i,-u,-s)
{%y}.datelabel format("YYYY")
next
endif
next
Expand Down
2 changes: 1 addition & 1 deletion R/import_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import_graph=function(wf="",page="*",graph="*",graph_procs="",save_options="",sa
chunkLabel=opts_current$get("label")

dev=opts_current$get('dev')
if(graph_procs=="" && !is.null(opts_current$get('graph_procs'))) graph_procs=opts_current$get('graph_procs')
if(identical(graph_procs,"") && !is.null(opts_current$get('graph_procs'))) graph_procs=opts_current$get('graph_procs')

graph1=graph

Expand Down
2 changes: 1 addition & 1 deletion man/EviewsR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/import_kable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d930fc9

Please sign in to comment.