{"id":18743066,"url":"https://github.com/kxsystems/rkdb","last_synced_at":"2025-10-04T17:10:13.573Z","repository":{"id":21606993,"uuid":"92966733","full_name":"KxSystems/rkdb","owner":"KxSystems","description":"R client for kdb+","archived":false,"fork":false,"pushed_at":"2024-12-06T09:34:01.000Z","size":605,"stargazers_count":42,"open_issues_count":11,"forks_count":29,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-10-02T01:43:46.366Z","etag":null,"topics":["interface","kdb","kdb-expression","q","r"],"latest_commit_sha":null,"homepage":"https://code.kx.com/q/interfaces","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KxSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-31T16:32:05.000Z","updated_at":"2025-04-17T08:35:54.000Z","dependencies_parsed_at":"2025-04-14T13:03:37.079Z","dependency_job_id":null,"html_url":"https://github.com/KxSystems/rkdb","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/KxSystems/rkdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Frkdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Frkdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Frkdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Frkdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KxSystems","download_url":"https://codeload.github.com/KxSystems/rkdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KxSystems%2Frkdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278343086,"owners_count":25971400,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["interface","kdb","kdb-expression","q","r"],"created_at":"2024-11-07T16:09:55.759Z","updated_at":"2025-10-04T17:10:13.529Z","avatar_url":"https://github.com/KxSystems.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# R client for kdb+\n\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/kxsystems/rkdb)](https://github.com/kxsystems/rkdb/releases) [![Travis (.org) branch](https://img.shields.io/travis/kxsystems/rkdb/master?label=travis%20build)](https://travis-ci.org/kxsystems/rkdb/branches) [![AppVeyor branch](https://img.shields.io/appveyor/ci/sv/rkdb/master?label=appveyor%20build)](https://ci.appveyor.com/project/sv/rkdb/branch/master)\n\n\nExecute kdb+ queries from R for advanced high-performance\nanalytics.\n\nA KX [Fusion interface](https://code.kx.com/q/interfaces).\n\n\n## Installation\n\n```r\n# remove old package\nif('rkdb' %in% rownames(installed.packages())) remove.packages('rkdb')\n# install devtools\nif(! 'devtools' %in% rownames(installed.packages())) install.packages('devtools')\nlibrary(devtools)\n# install rkdb\ndevtools::install_github('kxsystems/rkdb', quiet=TRUE,INSTALL_opts=c(\"--no-multiarch\"))\n# to install rkdb of particular release\n# devtools::install_github('kxsystems/rkdb@v0.10.0', quiet=TRUE)\nlibrary(rkdb)\n```\n\n\n## First steps\n\n\n### Set up a connection\n\nStart a kdb+ process to test the installation.\n\n```bash\nq -p 5000\n```\n\nOpen a connection to it.\n\n```r\nh \u003c- open_connection('localhost',5000)\n```\n\n\n### Hello kdb+\n\nYou can evaluate any kdb+ expression and its result will come back to R:\n\n```r\nexecute(h, '1+1')\n\n    ## [1] 2\n```\n\nAssigning a variable in the q workspace also works:\n\n```r\nexecute(h, 'x:1+1') #assign x to 2\n\n    ## NULL\n\nexecute(h, 'x') # get back the value\n\n    ## [1] 2\n```\n\n\n## Getting data from kdb+ to R\n\nKdb+ uses some basic types that might not have a direct equivalent in R.\nNote also that this is not a bijective operation. The conversions (from\nkdb to R) are:\n\n| kdb/q                       | r            |\n| --------------------------- | ------------ |\n| boolean                     | logical      |\n| byte                        | raw          |\n| short                       | integer      |\n| int                         | integer      |\n| long                        | integer64    |\n| real                        | numeric      |\n| float                       | numeric      |\n| char                        | character    |\n| symbol                      | character    |\n| timestamp                   | nanotime     |\n| month                       | integer      |\n| date                        | Date         |\n| datetime                    | POSIXct      |\n| timespan                    | integer64    |\n| minute                      | difftime     |\n| second                      | difftime     |\n| time                        | integer      |\n| enumeration                 | character    |\n| table                       | data.frame   |\n| keyed table                 | data.frame   |\n| dictionary (mixed types)    | named list   |\n| dictionary (same types)     | named vector |\n| function                    | character    |\n| list (same types)           | vector       |\n| list (same ‘complex’ types) | list         |\n| list (different types)      | list         |\n\n\n## Computing on kdb+\n\nRkdb provides a convenient way to retrieve computation done on the kdb+\nside so you can have the best of both worlds:\n\n```r\nkdb \u003c- '\nt: ([] x:1000#`a`b`c;y:1000#1f*til 10;z:1000#1f*til 4);\nselect sum y, dev z by x from t\n'\n\nexecute(h, kdb)\n\n    ##   x    y        z\n    ## 1 a 1503 1.120709\n    ## 2 b 1497 1.116689\n    ## 3 c 1500 1.116689\n```\n\nOne can for instance use R graphical capabilities:\n\n``` r\nkdb \u003c- '\nt: ([] x:1000#`a`b`c;y:1000#1f*til 10;z:1000#1f*til 4);\nselect y,z from t where x=`a\n'\n\nDF \u003c- execute(h, kdb)\nplot(DF$y, DF$z, main='scatter plot', xlab='y values', ylab='z values')\n```\n\n![](doc/figures/example-1.png)\u003c!-- --\u003e\n\n\n## Getting data from R to kdb+\n\n### Evaluating kdb+ expressions using R objects\n\nYou can call kdb+ functions with R objects as arguments. They will be\npassed and converted to native kdb+ data types, and the kdb+ expression\nwill be evaluated:\n\n```r\nexecute(h, \"raze\", list(c(1,2,3), c(4,5,6)))\n\n    ## [1] 1 2 3 4 5 6\n\nexecute(h, \"+\", 2, 5)\n\n    ## [1] 7\n\nexecute(h,'{`tmp set x}',data.frame(a=c(1,2,3),b=c(\"a\",\"b\",\"b\")))\n\n    ## [1] \"tmp\"\n```\n\nFor example, here is how you can use the left-join function on two\ndata frames:\n\n``` r\nDF1 \u003c- data.frame(x=c('x','x','y','y'), y=1:4)\nDF2 \u003c- data.frame(x=c('x','y','z'), z=seq(10,30,10))\nexecute(h, \"{[x;y] x lj `x xkey y}\", DF1, DF2)\n\n    ##   x y  z\n    ## 1 x 1 10\n    ## 2 x 2 10\n    ## 3 y 3 20\n    ## 4 y 4 20\n```\n\n## :open_file_folder: Documentation\n\n*   [User guide](docs/README.md)\n*   [Using R with kdb+](docs/r-and-q.md)\n*   [Other methods](docs/other-methods.md)\n\n---\n\nSee [code.kx.com/q/interfaces](https://code.kx.com/q/interfaces) for other interfaces to and from kdb+.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Frkdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkxsystems%2Frkdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkxsystems%2Frkdb/lists"}