generated from rpkgs/rpkg.template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
78 lines (60 loc) · 1.65 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.width = 10, fig.height = 5,
fig.align = "center",
fig.path = "man/Figure/",
dev = 'svg'
)
```
# tidydb2
<!-- badges: start -->
[![R-CMD-check](https://github.com/rpkgs/tidydb2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rpkgs/tidydb2/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/rpkgs/tidydb2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rpkgs/tidydb2)
<!-- [![CRAN](http://www.r-pkg.org/badges/version/tidydb2)](https://cran.r-project.org/package=tidydb2) -->
<!-- [![total](http://cranlogs.r-pkg.org/badges/grand-total/tidydb2)](https://www.rpackages.io/package/tidydb2) -->
<!-- [![monthly](http://cranlogs.r-pkg.org/badges/tidydb2)](https://www.rpackages.io/package/tidydb2) -->
<!-- badges: end -->
## Goals
> 更便捷的访问数据库
建立气象数据库,一行命令查询数据。
## TODO
- [ ] 读取数据的性能测试
- [ ] 添加写入数据的函数
## Installation
```r
remotes::install_github("rpkgs/tidydb2")
```
## Example
```r
## 查找邻近站点的数据
library(tidymet)
st <- st_met2176_hourly
p <- c(116.4, 39.9)
find_near(p, st)
```
```{r}
library(tidydb2)
library(dplyr)
library(Ipaper)
## hourly气象数据
dbinfo <- get_dbInfo("duckdb")
f <- dbinfo$hourly_2020_2022$db
db <- dbase$new(f)
db
site0 = 50246L
date0 <- make_datetime(2022, 1, 1, 0)
# 0.1s可以读回数据, 这里应该是UTC时间
system.time(
d <- db$tbl |>
filter(site == site0, date > date0) |>
select(date, PRS, TEM, RHU, tigan) |>
collect()
)
print(d)
db$close()
```