{"id":13529479,"url":"https://github.com/dleutnant/influxdbr","last_synced_at":"2026-02-19T23:01:19.766Z","repository":{"id":34759020,"uuid":"38740362","full_name":"dleutnant/influxdbr","owner":"dleutnant","description":"R Interface for InfluxDB","archived":false,"fork":false,"pushed_at":"2024-08-09T06:54:51.000Z","size":308,"stargazers_count":93,"open_issues_count":22,"forks_count":34,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-12-09T22:00:19.936Z","etag":null,"topics":["database","influxdb","r","rstats","tidyverse","timeseries"],"latest_commit_sha":null,"homepage":"https://cran.r-project.org/package=influxdbr","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dleutnant.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-07-08T07:59:50.000Z","updated_at":"2025-03-22T10:51:13.000Z","dependencies_parsed_at":"2024-01-02T23:41:45.963Z","dependency_job_id":"3fd5cf46-2dfb-4c7a-bbdb-bad68f48d39a","html_url":"https://github.com/dleutnant/influxdbr","commit_stats":{"total_commits":240,"total_committers":10,"mean_commits":24.0,"dds":"0.27083333333333337","last_synced_commit":"cb73bc50a50d2c72b7c4404274c209a784d57fcb"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dleutnant/influxdbr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleutnant%2Finfluxdbr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleutnant%2Finfluxdbr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleutnant%2Finfluxdbr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleutnant%2Finfluxdbr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dleutnant","download_url":"https://codeload.github.com/dleutnant/influxdbr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dleutnant%2Finfluxdbr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29636035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["database","influxdb","r","rstats","tidyverse","timeseries"],"created_at":"2024-08-01T07:00:36.696Z","updated_at":"2026-02-19T23:01:19.739Z","avatar_url":"https://github.com/dleutnant.png","language":"R","funding_links":[],"categories":["Client libraries"],"sub_categories":["Unofficial"],"readme":"---\ntitle: \"influxdbr\"\noutput: github_document  \n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\nSys.setenv(LANG = \"en\")\n```\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/influxdbr)](https://cran.r-project.org/package=influxdbr) [![Build Status](https://travis-ci.org/dleutnant/influxdbr.svg?branch=master)](https://travis-ci.org/dleutnant/influxdbr)\n\nR interface to [InfluxDB](https://docs.influxdata.com/influxdb)\n\nThis package allows you to fetch and write time series data from/to an InfluxDB server.\nAdditionally, handy wrappers for the Influx Query Language (IQL) to manage and explore a remote database are provided.\n\n## Installation\n\nInstallation is easy thanks to CRAN:\n```{r cran, eval = FALSE}\ninstall.packages(\"influxdbr\")\n```\n\nYou can install the dev version from github with:\n```{r gh-installation, eval = FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"dleutnant/influxdbr\")\n```\n\n## Example\n\nThis is a basic example which shows you how to communicate (i.e. query and write data)\nwith the InfluxDB server.\n\n```{r libs}\nlibrary(dplyr)\nlibrary(influxdbr)\nlibrary(xts)\n```\n\nLet's create first some sample data from the xts package and assign arbitrary \nattributes:\n\n```{r sample}\n# attach data \"sample_matrix\"\ndata(\"sample_matrix\")\n\n# create xts object\nxts_data \u003c- xts::as.xts(x = sample_matrix)\n\n# assign some attributes\nxts::xtsAttributes(xts_data) \u003c- list(info = \"SampleDataMatrix\",\n                                     UnitTesting = TRUE, \n                                     n = 180,\n                                     source = \"xts\")\n                                     \n# print structure to inspect the object\nstr(xts_data)\n```\n\n### InfluxDB connection\n\nTo connect to an InfluxDB server, we need a connection object. A connection object \ncan be created by providing usual server details (e.g. `host`, `port`, ...) or with\nhelp of a group file, which conveniently holds all information for us (s. package \ndocumentation):\n\n```{r connection}\n# create connection object \n# (here: based on a config file with group \"admin\" in it (s. package documentation))\ncon \u003c- influx_connection(group = \"admin\")\n```\n\nThe `influxdbr` package provides handy wrappers to manage a remote InfluxDB:\n\n```{r db_management}\n# create new database\ncreate_database(con = con, db = \"mydb\")\n\n# list all databases\nshow_databases(con = con) %\u003e% \n  filter(name == \"mydb\") # show the db created above only\n```\n### Write data\n\n#### xts\n\nWriting an xts-object to the server can be achieved with `influx_write`. In this \ncase, columnnames of the `xts` object are used as InfluxDB's field keys,\n`xts`'s coredata represent field values. Attributes are preserved and written\nas tag keys and values, respectively.\n\n```{r write_xts}\n# write example xts-object to database\ninflux_write(con = con, \n             db = \"mydb\",\n             x = xts_data, \n             measurement = \"sampledata\")\n```\n\n#### data.frame\n\nWriting a data.frame (or tibble) to the server can also be achieved with\n`influx_write`. In this case, we need to specify which columns of the data.frame \nrepresent time and tags. Fields are automatically determined.Each row represents\na unique data point. `NA`'s are not supported and need to be removed. \nTimestamps should be located in column `time`.\n\nRemember that time and tags are optional: InfluxDB uses the server’s local \nnanosecond timestamp in UTC if the timestamp is not included with the point.\n\n```{r write_df}\n# convert the existing xts-object to data.frame\ndf_data \u003c- dplyr::bind_cols(time = zoo::index(xts_data), # timestamp\n                            data.frame(xts_data)) %\u003e% # coredata\n  dplyr::mutate(info = \"SampleDataMatrix\", # add tag 'info'\n                UnitTesting = TRUE, # add tag 'UnitTesting'\n                n = row_number(), # add tag 'n'\n                source = \"df\")  # add source 'df'\n\ndf_data\n\n# write example data.frame to database\ninflux_write(con = con, \n             db = \"mydb\",\n             x = df_data,\n             time_col = \"time\", tag_cols = c(\"info\", \"UnitTesting\", \"n\", \"source\"),\n             measurement = \"sampledata\")\n```\n\nWe can now check if the time series were successfully written:\n\n```{r check_write_xts}\n# check if measurements were succefully written\nshow_measurements(con = con, db = \"mydb\")\n```\n\n### Query data\n\nTo query the database, two functions `influx_query` and `influx_select` are available.\n`influx_select` wraps around `influx_query` and can be useful for simple requests \nbecause it provides default query parameters. The return type can be configured \nto be of class `tibble` or of class `xts`.\n\n#### Return tibbles\n\nIf `return_xts = FALSE` a list of tibbles per query statement is returned. Each tibble contains columns with statement_id, series_names, tags, time and fields.\n\n```{r return_tibble}\n# fetch time series data by using the helper function `influx_select`\nresult \u003c- influx_select(con = con, \n                        db = \"mydb\", \n                        field_keys = \"Open, High\", \n                        measurement = \"sampledata\",\n                        where = \"source = 'df'\",\n                        group_by = \"*\",\n                        limit = 10, \n                        order_desc = TRUE, \n                        return_xts = FALSE)\n\nresult\n```\n\n#### Return xts\n\nIf `return_xts = TRUE` a list of xts objects per query statement is returned. Because xts objects are basically matrices (which can store one data type only), a single xts object is created for each InfluxDB field. This ensures a correct representation of the field values data type (instead of getting all into a \"character\" matrix). InfluxDB tags are now xts attributes.\n\n```{r return_xts}\n# fetch time series data by using the helper function `influx_select`\nresult \u003c- influx_select(con = con, \n                        db = \"mydb\", \n                        field_keys = \"Open, High\", \n                        measurement = \"sampledata\",\n                        where = \"source = 'xts'\",\n                        group_by =  \"*\",\n                        limit = 10, \n                        order_desc = TRUE, \n                        return_xts = TRUE)\n\nstr(result)\n```\n#### Simplify InfluxDB response\n\nIn case the InfluxDB response is expected to be a single series only, \nwe can flatten the list (`simplifyList = TRUE`) to directly get to the data.\nThis enhances a pipeable work flow.\n\n```{r simplify_response}\nresult \u003c- influx_select(con = con, \n                        db = \"mydb\", \n                        field_keys = \"Open\", \n                        measurement = \"sampledata\",\n                        where = \"source = 'df'\",\n                        group_by =  \"*\",\n                        limit = 10, \n                        order_desc = TRUE, \n                        return_xts = FALSE, \n                        simplifyList = TRUE)\n\nstr(result)\n```\n\n## Contributions\nThis Git repository contains the latest contributions to the R package `influxdbr` and other code that will appear in the next [CRAN](https://cran.r-project.org/package=influxdbr) release.\n\nContributing to this package is easy. Just send a [pull request](https://help.github.com/articles/using-pull-requests/). Your PR should pass `R CMD check --as-cran`, which will also be checked by \u003ca href=\"https://travis-ci.org/dleutnant/influxdbr\"\u003eTravis CI\u003c/a\u003e when the PR is submitted.\n\n## Code of conduct\nPlease note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.\n\n## Citation\n\n```{r citation, echo=FALSE, results='asis'}\ncitation(\"influxdbr\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdleutnant%2Finfluxdbr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdleutnant%2Finfluxdbr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdleutnant%2Finfluxdbr/lists"}