The rSharp R package provides access to .NET libraries from R. It allows to create .NET objects, access their fields, and call their methods.
This package is based on the rClr package and utilizes some of its code base.
Important notes
As rSharp is provided with precompiled binary files, it is currently a binary package.
The package utilizes two code bases - the R code which is exposed to the user, and the C++/C# code that communicates with the .NET libraries. The end user of the package will only interact with the R code, and pre-build C++/C# libraries are supplied with the package. See section Installation for instructions on how to install the package.
Advanced users and C++/C# developers might want to build the C++/C# code from source. For this, follow the instructions in section Build.
Installation
Prerequisites
Windows
- Latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 available here
- .NET 10 runtime for Windows x64
MacOS
Only Apple Silicon (arm64) is supported; no native binary is shipped for macOS x86_64.
- .NET 10 runtime for macOS arm64 (select the macOS tab and the Arm64 installer)
Install the package
Once the prerequisites for your operating system are in place, install rSharp with pre-built binaries from the OSP R-universe:
install.packages(
"rSharp",
repos = c(
OSP = "https://open-systems-pharmacology.r-universe.dev",
getOption("repos")
)
)Get the latest development version from GitHub with:
# install.packages("pak")
pak::pak("Open-Systems-Pharmacology/rSharp")Build
Windows
To build the C++/C# libraries from source, make sure the Desktop development with C++ workload is installed in Visual Studio.
Create an environment variable R_INSTALL_PATH and set the value to the path where R is installed
Start Visual Studio and open the rSharp.sln solution file and build the solution. The build process will automatically copy the required files to the rSharp/inst/lib folder.
Then start your preferred R environment and run the following R commands from within the rSharp folder
Ubuntu
Set up .NET SDK and nuget (the latter to get the required dependencies)
Optionally set up to build the binaries
Navigate to the rSharp\shared directory and run
Then change back to the rSharp directory start your preferred R environment and run the following R commands
MacOS
Only Apple Silicon (arm64) is supported.
Download and install the .NET SDK 10 for macOS arm64
Install Homebrew and use it to install build tools
Navigate to the rSharp\shared directory and run
Then change back to the rSharp directory start your preferred R environment and run the following R commands
User guide
Examples of interacting with .NET assemblies using this package are detailed in vignette('user-guide'). Some useful tips around using the package are available in the vignette('knowledge-base').
Code of conduct
Everyone interacting in the Open Systems Pharmacology community (codebases, issue trackers, chat rooms, mailing lists etc…) is expected to follow the Open Systems Pharmacology code of conduct.
Contribution
We encourage contribution to the Open Systems Pharmacology community. Before getting started please read the contribution guidelines. If you are contributing code, please be familiar with the coding standards.
License
The rSharp package is released under the GPLv2 License.
All trademarks within this document belong to their legitimate owners.