install.packages("torch")
torch::install_torch() # downloads libtorch the first time
torch::torch_is_installed() # should return TRUE1 Get Started
1.1 Installation
sconjoint runs on the torch deep-learning backend, which bundles its own copy of libtorch (downloaded on first use). Install torch first and confirm its native library loads:
Then install sconjoint from CRAN. It has been submitted; until it is accepted this line stays commented out — install a development version instead (see Section 1.2):
# install.packages("sconjoint")On CPU-only machines this is all you need. On a CUDA-enabled GPU, follow https://torch.mlverse.org to install the CUDA build of libtorch; scfit(device = "cuda") then uses it automatically. (The bit-exact determinism guarantee — identical sc_fit output regardless of n_cores — holds only on CPU.)
1.2 Versions
Until the CRAN release, install from GitHub. The development branches carry features ahead of CRAN:
| Source | Version | What it adds |
|---|---|---|
| CRAN | 0.2.1 | The released version (default), pending acceptance |
GitHub @dev |
0.2.1 | Development version; currently matches the CRAN submission |
GitHub @feat/torch-threads |
0.2.1.9000 | Newest in-progress work: the torch_threads Windows-stability control and the attribute-interaction extension, pending merge to dev after the release |
Install a specific source with the @branch suffix:
# install.packages("remotes")
remotes::install_github("xuyiqing/sconjoint@dev") # development version
remotes::install_github("xuyiqing/sconjoint@feat/torch-threads") # newest featuresCheck which version is installed on this computer:
packageVersion("sconjoint")[1] '0.2.1.9000'
Once sconjoint is on CRAN, install.packages("sconjoint") gives the latest release and remotes::install_version("sconjoint", "0.2.1") pins a specific one. Installing sconjoint pulls in ggplot2, ggridges, and related plotting packages automatically; no extra setup is needed for the visualization methods in the Plot Options chapter.
scfit()
A session abort (the R process exits, rather than throwing an R error) almost always comes from the native libtorch backend, not from sconjoint itself. It has been reported on some Windows systems while the same code runs fine on macOS. Things to try, in order:
Confirm
torchworks in isolation. In a fresh session, runlibrary(torch); x <- torch_randn(3, 3); x %*% x. If that aborts, the problem is thetorch/libtorchinstallation or your environment, notsconjoint: reinstall withtorch::install_torch(), and check whether security or endpoint-protection software is blocking thelibtorchDLLs (a common cause on managed corporate Windows machines).Cap torch’s threads with
torch_threads = 1. torch’s default multi-threaded CPU backend aborts the session on some Windows configurations, and running it single-threaded often avoids it. Thetorch_threadsargument toscfit()is the targeted fix for this (issue #7). It currently lives on thefeat/torch-threadsbranch, pending merge todevafter the next release, so install that branch first:remotes::install_github("xuyiqing/sconjoint@feat/torch-threads") library(sconjoint) fit <- scfit(formula, data, ..., torch_threads = 1)torch_threads = 1changes only the threading, not the results, and torch honors the thread count only on the first such call of a session — so set it before running any other torch work.Try plain
R(Rtermor the console) rather than an IDE, to rule out an IDE-specific interaction.