-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
138 lines (105 loc) · 4.97 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# RClimacell <a href='https://nikdata.github.io/RClimacell/'><img src='man/figures/rclimacell-hex.png' align="right" width="150" height="150" />
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![GitHub commit](https://img.shields.io/github/last-commit/nikdata/RClimacell)](https://github.com/nikdata/RClimacell/commit/main)
[![R-CMD-check](https://github.com/nikdata/RClimacell/workflows/R-CMD-check/badge.svg)](https://github.com/nikdata/RClimacell/actions)
[![CRAN status](https://www.r-pkg.org/badges/version/RClimacell)](https://CRAN.R-project.org/package=RClimacell)
<!-- badges: end -->
The {RClimacell} package is an **unofficial** R package that enables basic interaction with [Climacell's](https://www.climacell.co) API using the [Timeline Interface](https://docs.climacell.co/reference/timeline-overview). The functions within this package are tested against some of the [Core data layers](https://docs.climacell.co/reference/data-layers-core).
Please note that using the functions within this package **require** a valid API key.
More information about the Climacell API can be found on their [docs](https://docs.climacell.co/reference/api-overview) page.
### Lubridate Issue
As of 24 Feb, there is a [known issue](https://github.com/tidyverse/lubridate/issues/928) with using the package {lubridate} and it seems to be affecting macOS users. The 'fix' has been to add the following line to the .Renviron file or the .Rprofile (I applied the code into the .Renviron file and it worked):
```r
TZDIR="/Library/Frameworks/R.framework/Resources/share/zoneinfo/"
```
{lubridate} version 1.7.10 fixes this issue and is available on CRAN.
## Installation
CRAN version can be installed as follows:
``` r
install.packages('RClimacell')
```
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("nikdata/RClimacell")
```
## Usage
Not every variable in each of the functions will have a value. Missing values are denoted by NA and indicate that the API did not return a value for the specific date/time and function call.
### Temperature
```{r temperature_example}
library(RClimacell)
climacell_temperature(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1d',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::days(3))
```
### Wind
```{r wind_example}
library(RClimacell)
climacell_wind(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1d',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::days(3))
```
### Precipitation
```{r}
library(RClimacell)
df_precip <- climacell_precip(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1h',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::days(3))
dplyr::glimpse(df_precip)
```
### Celestial (sunset time, sunrise time, and moon phase)
```{r}
library(RClimacell)
df_celestial <- climacell_celestial(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1d',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::days(5))
dplyr::glimpse(df_celestial)
```
### Climacell Core (all Core Layer data)
This function aims to retrieve all of the Core Layer data using the Timeline Interface. All of the data are retrieved in a single API call. Note that if the timestep is not '1d', then the moon phase, sunrise time, and sunset times will not be available
```{r}
library(RClimacell)
df_core <- climacell_core(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1m',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::hours(3))
dplyr::glimpse(df_core)
```
```{r}
library(RClimacell)
df_core2 <- climacell_core(api_key = Sys.getenv("CLIMACELL_API"),
lat = 41.878685,
long = -87.636011,
timestep = '1d',
start_time = lubridate::now(),
end_time = lubridate::now() + lubridate::days(5))
dplyr::glimpse(df_core2)
```
See the [vignette](https://nikdata.github.io/RClimacell/) for more information.