threadleR
threadleR is an R package that provides a seamless interface to Threadle, enabling R users to work with large-scale network data directly from their R environments. The threadleR R package is developed and maintained by Yukun Jiao, student at the Masters program in Computational Social Science at Linköping University, Sweden. Similar to Threadle, threadleR is open source and available here:
https://github.com/YukunJiao/threadleR/
How it works
threadleR communicates with the Threadle CLIconsole through a child process, sending commands as JSON and receiving structured results back. This means:
- Networks and Nodesets stay in Threadle''s memory-efficient engine
- R receives only the data you request (query results, statistics, samples)
- Best of both worlds: R's analytical ecosystem and Threadle's scalability
Examples
For a thorough tutorial to threadleR and its functions, click here. You will find the .Rmd to this tutorial at Yukun's threadleR repository.
Installation
From file (offline environments)
- Download the package file from the Download page.
- From R, make sure that your working directory is where you downloaded the file.
- Install it in your R environment (or use the .zip ending if on Windows):
install.packages("threadleR_0.4.3.tar.gz", repos = NULL, type = "source")
From GitHub (online environments)
threadleR can easily be installed directly from its GitHub repository into your R environment:
# Option 1 (recommended) # First, make sure to have the 'remotes' package installed. If not, uncomment and run the following # install.packages("remotes") remotes::install_github("YukunJiao/threadleR") # Option 2 # install.packages("pak") pak::pak("YukunJiao/threadleR")
To use threadleR, make sure to load the library in your code:
library(threadleR)
Starting and stopping Threadle from threadleR
Check whether Threadle is available
th_is_available() checks whether the threadle executable can be found on your system.
th_is_available()
If it returns FALSE, either add the executable to your PATH (or similar), or start Threadle with an explicit path:
th_start_threadle("/full/path/to/threadle")
Starting Threadle
Start the Threadle background process (i.e. the CLIconsole):
th_start_threadle()
Stop Threadle
Stop the Threadle process when you are done working:
th_stop_threadle()
# Threadle process terminated.
Working directory
Threadle has its own working directory. Many file-based commands (especially th_load_file()) depend on it. To inspect Threadle working directory:
th_get_workdir()
To set it, either use an absolute path, a relative path from the current working directory:
th_get_workdir()
You can also use two in-built shortcuts for either getting to the root of your user account - '~' - or the root of your Documents (or equivalent) folder: '~documents':
th_set_workdir("~documents")
To get Threadle aligned with the current R working directory:
th_sync_wd()