{"id":15165875,"url":"https://github.com/zitsen/libr.rs","last_synced_at":"2026-01-21T21:35:13.649Z","repository":{"id":62442111,"uuid":"46246275","full_name":"zitsen/libr.rs","owner":"zitsen","description":"A library for types and bingings to native C functions in libR in Rust","archived":false,"fork":false,"pushed_at":"2018-03-20T06:53:57.000Z","size":1301,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T01:33:34.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zitsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-16T02:09:12.000Z","updated_at":"2021-03-26T10:11:02.000Z","dependencies_parsed_at":"2022-11-01T23:18:13.572Z","dependency_job_id":null,"html_url":"https://github.com/zitsen/libr.rs","commit_stats":null,"previous_names":["zisten/libr.rs"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zitsen/libr.rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitsen%2Flibr.rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitsen%2Flibr.rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitsen%2Flibr.rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitsen%2Flibr.rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zitsen","download_url":"https://codeload.github.com/zitsen/libr.rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zitsen%2Flibr.rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28644149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-27T04:05:32.996Z","updated_at":"2026-01-21T21:35:13.631Z","avatar_url":"https://github.com/zitsen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"libr\n====\n\n**NOTE: Now I cannot publish libr to its crate name because crates.io says I'm not the owner. The crate name will be changed when I will.**\n\nNative C types and bindings of libR.\n\n[![Build Status](https://travis-ci.org/zisten/libr.rs.svg?branch=master)](https://travis-ci.org/zisten/libr.rs)\n\n[Documentation](http://zisten.github.io/libr.rs/libr/index.html)\n\n## Usage\n\nFirst, add the following to your Cargo.toml:\n\n```toml\n[dependencies]\nlibr = 0.1\n```\n\nNext, add this to your crate root:\n\n```rust\nextern crate libr;\n```\n\n## What is libr?\n\nThe primary purpose of this crate is to provide an easily\ninterface for embedding R functions. This include type\ndefinitions (e.g. `SEXP`), constants(e.g. `PI`) as well as\nfunction headers(e.g. `Rf_initEmbeddedR`)\n\nThe library now support 64bit Linux only, for the case\nI have no idea to how to test it in other system. I'm\na newer in [Rust](http://rust-lang.org), so it's so welcome\nfor help and suggestions.\n\n## Examples\n\n### For a similar native R-like app, use this:\n\n```rust\nextern crate libr;\nuse std::env;\nuse std::ffi::CString;\nuse libr::embedded::Rf_initialize_R;\nuse libr::interface::*;\n\nfn main() {\n    if let Err(_) = env::var(\"R_HOME\") {\n        panic!(\"Rembedded test need R_HOME be setted\");\n    }\n    let args = vec![\"R\", \"--no-save\"];\n    let mut args = args.into_iter()\n       .map(|arg|\n           CString::new(arg.as_bytes()).unwrap().into_raw())\n       .collect::\u003cVec\u003c_\u003e\u003e();\n    unsafe {\n       R_running_as_main_program = 1;\n       Rf_initialize_R(args.len() as i32, args.as_mut_ptr());\n       Rf_mainloop();\n       return;\n    }\n}\n```\n\n### R math functions\n\nSee details in [math](math/index.html).\n\n```rust\nextern crate libr;\nuse libr::math::R_pow;\n\nfn main() {\n    assert_eq!(unsafe { R_pow(2., 3.) }, 8.);\n}\n```\n\n### Embedded R\n\nSee details documents in [embedded module](embedded/index.html).\n\n```rust\nextern crate libr;\nuse std::env;\nuse std::ffi::CString;\n\nuse libr::internals::*;\nuse libr::embedded as Rembedded;\nuse libr::ext::parse::{ParseStatus, R_ParseVector};\n\nfn main() {\n    if let Err(_) = env::var(\"R_HOME\") {\n        panic!(\"Rembedded test need R_HOME be setted\");\n    }\n    let mut s = Box::new(vec![CString::new(\"R\").unwrap().into_raw(),\n                         CString::new(\"--quiet\").unwrap().into_raw(),\n                         CString::new(\"--no-save\").unwrap().into_raw()]);\n    unsafe {\n        Rembedded::Rf_initEmbeddedR(s.len() as i32, s.as_mut_ptr());\n        // Plot\n        let mut status = ParseStatus::PARSE_OK;\n        let mut had_error = 0;\n        let tmp = Rf_protect(Rf_mkString(CString::new(\"{pdf(\\\"03-plot.pdf\\\"); plot(1:10, \\\n                                                        pch=\\\"+\\\"); print(1:10)}\")\n                                            .unwrap()\n                                            .into_raw()));\n        let e = Rf_protect(R_ParseVector(tmp, 1, \u0026mut status, R_NilValue));\n        Rf_PrintValue(e);\n        R_tryEval(VECTOR_ELT(e, 0), R_GlobalEnv, \u0026mut had_error);\n        Rf_unprotect(2);\n        Rembedded::Rf_endEmbeddedR(0);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzitsen%2Flibr.rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzitsen%2Flibr.rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzitsen%2Flibr.rs/lists"}