{"id":25806012,"url":"https://github.com/alipsa/rdatautil","last_synced_at":"2026-05-14T15:36:56.348Z","repository":{"id":57745379,"uuid":"457430296","full_name":"Alipsa/rdatautil","owner":"Alipsa","description":"Utility to read and write RData (rds) files in java","archived":false,"fork":false,"pushed_at":"2022-02-11T11:54:27.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-01T11:27:03.146Z","etag":null,"topics":["jvm","r"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Alipsa.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":"2022-02-09T16:06:06.000Z","updated_at":"2022-02-16T20:04:39.000Z","dependencies_parsed_at":"2022-08-30T23:40:12.895Z","dependency_job_id":null,"html_url":"https://github.com/Alipsa/rdatautil","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Frdatautil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Frdatautil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Frdatautil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Frdatautil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alipsa","download_url":"https://codeload.github.com/Alipsa/rdatautil/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241052529,"owners_count":19901043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["jvm","r"],"created_at":"2025-02-27T19:52:38.856Z","updated_at":"2026-05-14T15:36:56.293Z","avatar_url":"https://github.com/Alipsa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rdatautil\nUtility to read and write RData (rds) files in java.\n\nRDS files are created in R:\n```R\n# Save a data.frame object to a file\nsaveRDS(mtcars, \"mtcars.rds\")\n```\n\n...and they can be read in R like this:\n```R\n# Restore it \nmy_data \u003c- readRDS(\"mtcars.rds\")\n```\n\nThis utility allows you to save and read such rsd files in java. It relies on the [Renjin project](https://github.com/bedatadriven/renjin) \nfor the heavy lifting.\n\n## Usage\n\nAdd the dependency to your pom (or equivalent):\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ese.alipsa\u003c/groupId\u003e\n    \u003cartifactId\u003erdatautil\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Read a rds file\nthe read method takes either a File or an InputStream as a parameter:\n\n```groovy\nimport se.alipsa.rdatautils.RDataUtil;\nimport org.renjin.sexp.SEXP;\n\nSEXP data = RDataUtil.read(new File(\"mtcars.rds\"));\n```\n\n```groovy\nimport se.alipsa.rdatautils.RDataUtil;\nimport org.renjin.sexp.SEXP;\n\nSEXP data = RDataUtil.read(getClass().getResourceAsStream(\"mtcars.rds\"));\n```\n\n### Write to a rds file\n```groovy\nimport se.alipsa.rdatautils.RDataUtil;\nimport org.renjin.sexp.SEXP;\nimport org.renjin.sexp.PairList;\n\nPairList.Builder file = new PairList.Builder();\nfile.add(\"names\", new StringArrayVector(\"Kurt\", \"Susan\", \"Zoe\", StringVector.NA));\nfile.add(\"income\", new IntArrayVector(120000, 220202, 303030, IntVector.NA));\nSEXP sexp = file.build();\n\n// You can write to a file\nRDataUtil.write(sexp, new File(\"employeeSalaries.rds\"));\n\n// or an OutputStream\nRDataUtil.write(sexp, System.out);\n```\n\n### Handling complex data\nThe [se.alipsa:renjin-client-data-utils](https://github.com/perNyfelt/renjin-client-data-utils) project enables you to \ndeal with tabular data and combines very well with rdatautil:\n\nReading data:\n```groovy\nimport se.alipsa.rdatautils.RDataUtil;\nimport org.renjin.sexp.SEXP;\nimport se.alipsa.renjin.client.datautils.Table;\n\nSEXP data = RDataUtil.read(getClass().getResourceAsStream(\"employeeSalaries.rds\"));\nTable table = Table.createTable(data);\n// Get the data.frame as a List of rows suitable for how data is usually handled in java:\nList\u003cList\u003cObject\u003e\u003e rows = table.getRowList();\n\n// You can also get an individual value\nString employee1 = table.getValueAsString(0,0);\n```\n\nWriting data:\n\n```java\nimport se.alipsa.rdatautils.RDataUtil;\nimport org.renjin.sexp.SEXP;\nimport se.alipsa.renjin.client.datautils.Table;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\nclass RdataSaver {\n  \n    public static void saveToRds(ResultSet rs, OutputStream os) throws SQLException {\n        Table table = new Table(rs);\n        RDataUtil.write(table.asDataframe(), os);\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Frdatautil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falipsa%2Frdatautil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Frdatautil/lists"}