1- # # ----store, opts.label='purlme'----------------------------------------------------------------------------------------------------
1+ # # ----store, opts.label='purlme'-----------------------------------------------
22# # Purl this first
33# # Store br.* objects in bloomr env in base namespace
44assign(' bloomr.usr' , new.env(parent = asNamespace(" stats" )))
@@ -18,7 +18,7 @@ store=function(sym){
1818}
1919
2020
21- # # ----br.bdh, opts.label='purlme'---------------------------------------------------------------------------------------------------
21+ # # ----br.bdh, opts.label='purlme'----------------------------------------------
2222br.bdh = function (
2323 con , securities , fields = " PX_LAST" , start.date , end.date = NULL ,
2424 option.names = NULL , option.values = NULL ,
@@ -32,7 +32,7 @@ br.bdh=function(
3232}
3333store(br.bdh )
3434
35- # # ----br.bulk.csv, opts.label='purlme'----------------------------------------------------------------------------------------------
35+ # # ----br.bulk.csv, opts.label='purlme'-----------------------------------------
3636br.bulk.csv = function (con , file , start = Sys.Date()- 5 , field = " PX_LAST" , cols = NULL ,
3737 addtype = FALSE , showtype = FALSE , use.xts = TRUE , comma = TRUE ,
3838 price = TRUE , nrow = 5 , same.dates = FALSE , no.na = FALSE , empty.sec = 0
@@ -77,7 +77,7 @@ br.bulk.csv=function(con, file, start=Sys.Date()-5, field="PX_LAST", cols=NULL,
7777}
7878store(br.bulk.csv )
7979
80- # # ----br.bulk.desc, opts.label='purlme'---------------------------------------------------------------------------------------------
80+ # # ----br.bulk.desc, opts.label='purlme'----------------------------------------
8181br.bulk.desc = function (con , tiks ) {
8282
8383 LL = lapply(tiks , function (tik ){
@@ -89,7 +89,7 @@ br.bulk.desc=function(con, tiks) {
8989}
9090store(br.bulk.desc )
9191
92- # # ----br.bulk.idx, opts.label='purlme'----------------------------------------------------------------------------------------------
92+ # # ----br.bulk.idx, opts.label='purlme'-----------------------------------------
9393br.bulk.idx = function (con , index , start = Sys.Date()- 5 , field = " PX_LAST" , showtype = FALSE ,
9494 include.idx = TRUE , use.xts = TRUE ,
9595 nsec = 10 , price = TRUE , nrow = 5 ,
@@ -139,7 +139,7 @@ br.bulk.idx=function(con, index, start=Sys.Date()-5, field="PX_LAST", showtype=F
139139}
140140store(br.bulk.idx )
141141
142- # # ----br.bulk.tiks, opts.label='purlme'---------------------------------------------------------------------------------------------
142+ # # ----br.bulk.tiks, opts.label='purlme'----------------------------------------
143143br.bulk.tiks = function (
144144 con ,
145145 tiks ,
@@ -223,7 +223,7 @@ br.bulk.tiks=function(
223223}
224224store(br.bulk.tiks )
225225
226- # # ----br.desc, opts.label='purlme'--------------------------------------------------------------------------------------------------
226+ # # ----br.desc, opts.label='purlme'---------------------------------------------
227227br.desc = function (con , tik )
228228{
229229
@@ -252,7 +252,7 @@ br.desc=function(con, tik)
252252}
253253store(br.desc )
254254
255- # # ----rmd-internal, opts.label='purlme'---------------------------------------------------------------------------------------------
255+ # # ----rmd-internal, opts.label='purlme'----------------------------------------
256256.br.addpaths <- function (pandonly = FALSE , quiet = TRUE ){
257257# ## Add to Windows System Path the executable directories of LaTeX, Pandoc, and Perl with this search priority, and
258258# ## return invisibly the original path. If "pandonly" is true, add only Pandoc. If "quiet" is false, print the new path.
@@ -270,9 +270,12 @@ store(br.desc)
270270 }
271271
272272 pandir <- xfind(" pandoc/bin/pandoc.exe" )
273- latdir <- xfind(" tinytex/bin/win32/latex.exe" )
274- perldir <- xfind(" tinytex/tlpkg/tlperl/bin/perl.exe" )
275-
273+ if (! pandonly ){
274+ latdir <- xfind(" tinytex/bin/win32/latex.exe" )
275+ perldir <- xfind(" tinytex/tlpkg/tlperl/bin/perl.exe" )
276+ .br.inittex()
277+ }
278+
276279 # # Add executable dirs to system path
277280 old.path <- Sys.getenv(' Path' )
278281 ap <- function (dir ) Sys.setenv(PATH = paste0(dir , " ;" , Sys.getenv(" PATH" )))
@@ -317,17 +320,22 @@ store(br.desc)
317320 })
318321}
319322
323+ .br.inittex <- function (){
324+ library(' tinytex' )
325+ options(tinytex.tlmgr.path = file.path(.br.home(), " tinytex/bin/win32/tlmgr.bat" ))
326+ }
320327
321328
322- # # ----br.md2pdf, opts.label='purlme'------------------------------------------------------------------------------------------------
329+
330+ # # ----br.md2pdf, opts.label='purlme'-------------------------------------------
323331br.md2pdf <- function (md.file , pdf.file , quiet = TRUE ){
324332# ## Make a markdown file into a PDF
325333# ## You need the proper BloomR version
326334
327335 # # Test arguments
328336 if (missing(md.file )) stop(" Argument 'md.file' missing." )
329337 if (missing(pdf.file )) pdf.file = paste0(tools ::: file_path_sans_ext(md.file ), ' .pdf' )
330-
338+
331339 # # Set executable paths and render
332340 cmd <- paste(" pandoc" , .br.wpath(md.file ), ' -o' , .br.wpath(pdf.file ))
333341 cmdexpr <- quote(system(cmd , intern = TRUE , invisible = FALSE ))
@@ -336,7 +344,7 @@ br.md2pdf <- function(md.file, pdf.file, quiet=TRUE){
336344}
337345store(br.md2pdf )
338346
339- # # ----br.rmd2html, opts.label='purlme'----------------------------------------------------------------------------------------------
347+ # # ----br.rmd2html, opts.label='purlme'-----------------------------------------
340348br.rmd2html <- function (rmd.file , html.file , quiet = TRUE ){
341349# ## Make an R Markdown file into a HTML self-contained file
342350# ## You need the proper BloomR edition
@@ -362,7 +370,7 @@ br.rmd2html <- function(rmd.file, html.file, quiet=TRUE){
362370}
363371store(br.rmd2html )
364372
365- # # ----br.rmd2slides, opts.label='purlme'--------------------------------------------------------------------------------------------
373+ # # ----br.rmd2slides, opts.label='purlme'---------------------------------------
366374br.rmd2slides <- function (rmd.file , html.file , quiet = TRUE ){
367375# ## Make an R Markdown file into a Google Slides self-contained HTML file
368376# ## You need proper BloomR edition
@@ -391,7 +399,7 @@ br.rmd2slides <- function(rmd.file, html.file, quiet=TRUE){
391399store(br.rmd2slides )
392400
393401
394- # # ----br.rmd2pdf, opts.label='purlme'-----------------------------------------------------------------------------------------------
402+ # # ----br.rmd2pdf, opts.label='purlme'------------------------------------------
395403br.rmd2pdf = function (rmd.file , pdf.file , quiet = TRUE ){
396404# ## Make an R Markdown file into a PDF
397405# ## You need BloomR LaTeX addons or the proper BloomR version
@@ -418,7 +426,7 @@ br.rmd2pdf=function(rmd.file, pdf.file, quiet=TRUE){
418426}
419427store(br.rmd2pdf )
420428
421- # # ----br.rmd2both, opts.label='purlme'----------------------------------------------------------------------------------------------
429+ # # ----br.rmd2both, opts.label='purlme'-----------------------------------------
422430br.rmd2both = function (rmd.file , quiet = TRUE ){
423431# ## Make an R Markdown file into a PDF and an HTML self-contained file
424432# ## You need BloomR LaTeX addons or the proper BloomR version
@@ -467,7 +475,7 @@ br.rmd2both=function(rmd.file, quiet=TRUE){
467475store(br.rmd2both )
468476
469477
470- # # ----br.sample, opts.label='purlme'------------------------------------------------------------------------------------------------
478+ # # ----br.sample, opts.label='purlme'-------------------------------------------
471479br.sample = function (nrow , nsec = 1 , price = TRUE , start = Sys.Date(), mean = ifelse(price , 10 , 0.1 ), sd = 1 ,
472480 jitter = 0 , same.dates = FALSE , no.na = FALSE , df = FALSE , empty.sec = 0 , sec.names = NULL )
473481{
@@ -534,13 +542,13 @@ br.sample=function(nrow, nsec=1, price=TRUE, start=Sys.Date(), mean=ifelse(price
534542}
535543store(br.sample )
536544
537- # # ----deprecated, opts.label='purlme'-----------------------------------------------------------------------------------------------
545+ # # ----deprecated, opts.label='purlme'------------------------------------------
538546bbg.open = function () stop(" Sorry 'bbg.open' is now deprecated. Please use br.open()." )
539547bbg.close = function (con ) stop(" Sorry 'bbg.close' is now deprecated. Please use br.close()." )
540548store(bbg.open )
541549store(bbg.close )
542550
543- # # ----bbg-internal, opts.label='purlme'---------------------------------------------------------------------------------------------
551+ # # ----bbg-internal, opts.label='purlme'----------------------------------------
544552
545553# # Check connection token
546554.br.is.con = function (con ) identical(attr(con , ' jclass' ), " org/findata/blpwrapper/Connection" )
@@ -577,14 +585,14 @@ store(.br.check.type)
577585store(.br.cuttype )
578586store(.br.jar )
579587
580- # # ----connections, opts.label='purlme'----------------------------------------------------------------------------------------------
588+ # # ----connections, opts.label='purlme'-----------------------------------------
581589br.open = function () blpConnect(blpapi.jar.file = .br.jar())
582590br.close = function (conn ) if (! is.null(conn )) blpDisconnect(conn )
583591
584592store(br.open )
585593store(br.close )
586594
587- # # ----miscfunc, opts.label='purlme'-------------------------------------------------------------------------------------------------
595+ # # ----miscfunc, opts.label='purlme'--------------------------------------------
588596
589597# Clean up
590598# # Remove visible and invisible objects
@@ -598,7 +606,7 @@ rm.var=function()
598606store(rm.all )
599607store(rm.var )
600608
601- # # ----betafun, opts.label='purlme'--------------------------------------------------------------------------------------------------
609+ # # ----betafun, opts.label='purlme'---------------------------------------------
602610
603611br.beta = function (){
604612 f = paste0(R.home(" share" ), " /bloomr/bloomr.beta.R" )
@@ -608,7 +616,7 @@ br.beta=function(){
608616store(br.beta )
609617
610618
611- # # ----time, opts.label='purlme'-----------------------------------------------------------------------------------------------------
619+ # # ----time, opts.label='purlme'------------------------------------------------
612620`%+%` <- function (x ,y ) UseMethod(" %+%" )
613621`%+%.Date` <- function (date ,n ) seq(date , by = paste (n , " months" ), length = 2 )[2 ]
614622`%-%` <- function (x ,y ) UseMethod(" %-%" )
@@ -664,7 +672,7 @@ store(last.day)
664672store(day.us )
665673
666674
667- # # ----attach, opts.label='purlme'---------------------------------------------------------------------------------------------------
675+ # # ----attach, opts.label='purlme'----------------------------------------------
668676# ## Make visible br.* in bloomr env and base ns
669677attach(bloomr.usr )
670678rm(store )
0 commit comments