knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The main parts of the bibliomatrix
package are:
First load some useful packages, including bibliomatrix
:
library(bibliomatrix) library(dplyr) library(stringr) library(readr) library(knitr) library(bench) library(DBI) library(pool) library(dbplyr) if (Sys.info()["sysname"] == "Windows") readRenviron(file.path(Sys.getenv("R_USER"), ".Renviron"))
In order to get data from the Microsoft SQL Server database, an .Renviron
file is currently required with values being provided for the following envvars: DBUSER
(the MSSQL Server service account name for the BIBMON db), DBPASS
, DBHOST
(the hostname for the MSSQL server) and DBNAME
(use "BIBMON").
Once this has been provided in the .Renviron
file, data for the ABM tables can be retrieved.
NOTE: For the public part of ABM, no database connection is needed, see Using bundled data in bibliomatrix.
# Open a connection pool to Microsoft SQL Server BIBMON database bibmon <- pool_bib("mssql") # get data for ABM table 1 kth_data <- abm_data(bibmon, unit_code = "KTH") t1 <- abm_table1(kth_data) # display first few results t1 %>% slice(1:5) %>% select(1:2) %>% kable() # You can build a sqlite3 databsae for local use (this will take a while the first time) db_sync() localdb <- pool_bib("sqlite") kth_data_local <- abm_data(localdb, unit_code = "KTH") t2 <- abm_table1(kth_data_local) # are the results the same? identical(t1, t2) # what about performance? bench_time(abm_table1(abm_data(con = bibmon, unit_code = "KTH"))) bench_time(abm_table1(abm_data(con = localdb, unit_code = "KTH"))) poolClose(bibmon) poolClose(localdb)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.