You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.0 KiB

---
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")
```
2 years ago
```{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.