Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrbrmstr/swiftr
Seamless R and Swift Integration
https://github.com/hrbrmstr/swiftr
r rstats swift
Last synced: 11 days ago
JSON representation
Seamless R and Swift Integration
- Host: GitHub
- URL: https://github.com/hrbrmstr/swiftr
- Owner: hrbrmstr
- License: other
- Created: 2021-01-24T10:07:50.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-06T13:09:27.000Z (about 1 year ago)
- Last Synced: 2024-10-12T21:24:02.444Z (26 days ago)
- Topics: r, rstats, swift
- Language: R
- Homepage:
- Size: 27.3 KB
- Stars: 25
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - hrbrmstr/swiftr - Seamless R and Swift Integration (R)
README
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
``````{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
``````{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```## What's Inside The Tin
The following functions are implemented:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```## Usage
```{r lib-ex}
library(swiftr)# current version
packageVersion("swiftr")```
```{r ex01}
swift_function(
code = 'func ignored() {
print("""
this will be ignored by swift_function() but you could use private
functions as helpers for the main public Swift function which will be
made available to R.
""")
}@_cdecl ("read_plist")
public func read_plist(path: SEXP) -> SEXP {
var out: SEXP = R_NilValue
do {
// read in the raw plist
let plistRaw = try Data(contentsOf: URL(fileURLWithPath: String(cString: R_CHAR(STRING_ELT(path, 0)))))
// convert it to a PropertyList
let plist = try PropertyListSerialization.propertyList(from: plistRaw, options: [], format: nil) as! [String:Any]
// serialize it to JSON
let jsonData = try JSONSerialization.data(withJSONObject: plist , options: .prettyPrinted)
// setup the JSON string return
String(data: jsonData, encoding: .utf8)?.withCString {
cstr in out = Rf_mkString(cstr)
}
} catch {
debugPrint("\\(error)")
}
return(out)
}
')read_plist("/Applications/RStudio.app/Contents/Info.plist") %>%
jsonlite::fromJSON() %>%
str(1)
```## swiftr Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```## Code of Conduct
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.