Skip to content

Commit 51a2d66

Browse files
author
Adam H. Sparks
committed
Polish vignette
1 parent 50eab86 commit 51a2d66

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

codemeta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
"applicationCategory": "Tools",
245245
"isPartOf": "https://ropensci.org",
246246
"keywords": ["anglia-cru", "climate-data", "cru-cl2", "temperature", "rainfall", "elevation", "data-access", "wind", "relative-humidity", "solar-radiation", "diurnal-temperature", "frost", "cru", "r", "rstats", "r-package", "peer-reviewed"],
247-
"fileSize": "909.747KB",
247+
"fileSize": "910.679KB",
248248
"citation": [
249249
{
250250
"@type": "ScholarlyArticle",
@@ -276,7 +276,7 @@
276276
],
277277
"releaseNotes": "https://github.com/ropensci/getCRUCLdata/blob/master/NEWS.md",
278278
"readme": "https://github.com/ropensci/getCRUCLdata/blob/main/README.md",
279-
"contIntegration": ["https://github.com/ropensci/getCRUCLdata/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/ropensci/getCRUCLdata"],
279+
"contIntegration": ["https://github.com/ropensci/getCRUCLdata/actions/workflows/R-CMD-check.yaml", "https://codecov.io/gh/ropensci/getCRUCLdata"],
280280
"developmentStatus": "https://www.repostatus.org/",
281281
"review": {
282282
"@type": "Review",

vignettes/getCRUCLdata.Rmd

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "getCRUCLdata"
33
author: "Adam H. Sparks"
4-
date: "2024-12-15"
4+
date: "2024-12-16"
55
output:
66
rmarkdown::html_vignette:
77
toc: true
@@ -12,6 +12,7 @@ vignette: >
1212
%\VignetteDepends{terra}
1313
%\VignetteDepends{ggplot2}
1414
%\VignetteDepends{viridis}
15+
%\VignetteDepends{data.table}
1516
---
1617

1718

@@ -64,7 +65,7 @@ The arguments for selecting the climatology elements for importing are:
6465
- **dsn** *For `create_CRU_stack()`* and *`create_CRU_df()`* only.
6566
Local file path where CRU CL v. 2.0 .dat.gz files are located.
6667

67-
### Creating tidy data frames for use in R
68+
### Creating data frames for use in R
6869

6970
The `get_CRU_df()` function automates the download process and creates data frames of the climatology elements.
7071

@@ -114,7 +115,7 @@ CRU_data
114115
#> 6795150: -35.80
115116
```
116117

117-
Perhaps you only need one or two elements, it is easy to create a tidy data frame of mean temperature only.
118+
Perhaps you only need one or two elements, it is easy to create a data frame of mean temperature only.
118119

119120

120121
``` r
@@ -136,7 +137,7 @@ t
136137
#> 6795144: 83.583 -36.750 dec -33.3
137138
```
138139

139-
#### Plotting data from the tidy dataframe
140+
#### Plotting data from the data frame
140141

141142
Now that we have the data, we can plot it easily using _ggplot2_ and the _viridis_ package for the colour scale.
142143

@@ -154,8 +155,8 @@ ggplot(data = t, aes(x = lon, y = lat, fill = tmp)) +
154155
```
155156

156157
<div class="figure" style="text-align: center">
157-
<img src="plot_t-1.png" alt="plot of chunk plot_t" />
158-
<p class="caption">plot of chunk plot_t</p>
158+
<img src="plot_t-1.png" alt="Maps of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991." />
159+
<p class="caption">Maps of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991.</p>
159160
</div>
160161

161162
We can also generate a violin plot of the same data to visualise how the temperatures change throughout the year.
@@ -170,25 +171,26 @@ ggplot(data = t, aes(x = month, y = tmp)) +
170171
```
171172

172173
<div class="figure" style="text-align: center">
173-
<img src="violin_plot-1.png" alt="plot of chunk violin_plot" />
174-
<p class="caption">plot of chunk violin_plot</p>
174+
<img src="violin_plot-1.png" alt="Monthly values of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991." />
175+
<p class="caption">Monthly values of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991.</p>
175176
</div>
176177

177-
#### Saving the tidy `data.frame` as a CSV (comma separated values file) locally
178+
#### Saving the `data.frame` as a CSV (comma separated values file) locally
178179

179-
Save the resulting tidy `data.frame` to local disk as a comma separated (CSV)
180+
Save the resulting `data.frame` to local disk as a comma separated (CSV)
180181
file to local disk, using _data.table_'s `fwrite()`.
181182

182183

183184
``` r
185+
library(data.table)
184186
fwrite(x = t, file = "~/CRU_tmp.csv")
185187
```
186188

187189
### Creating terra raster stacks for use in R and saving for use in another GIS
188190

189191
For working with spatial data, _getCRUCLdata_ provides a function that create lists of _terra_ stacks of the data.
190192

191-
The `get_CRU_stack()` functions provide similar functionality to `get_CRU_df()`, but rather than returning a tidy data frame, it returns a list of `terra::rast()` objects for use in an R session.
193+
The `get_CRU_stack()` functions provide similar functionality to `get_CRU_df()`, but rather than returning a data frame, it returns a list of `terra::rast()` objects for use in an R session.
192194

193195
The `get_CRU_stack()` function automates the download process and creates a `terra::rast()` object of the CRU CL v. 2.0 climatology elements.
194196
Illustrated here is creating a `terra::rast()` of all CRU CL v. 2.0 climatology elements available.
@@ -209,10 +211,6 @@ CRU_stack <- get_CRU_stack(
209211
wnd = TRUE,
210212
elv = TRUE
211213
)
212-
#>
213-
|---------|---------|---------|---------|
214-
=========================================
215-
216214

217215
CRU_stack
218216
#> $dtr
@@ -254,7 +252,7 @@ CRU_stack
254252
#> resolution : 0.1666667, 0.1666667 (x, y)
255253
#> extent : -180, 180, -60, 85 (xmin, xmax, ymin, ymax)
256254
#> coord. ref. : lon/lat WGS 84
257-
#> source : spat_fe274b2a6660_65063_GdaPwXHptgIOPSx.tif
255+
#> source : spat_613232ecfe11_24882_GdaPwXHptgIOPSx.tif
258256
#> names : jan, feb, mar, apr, may, jun, ...
259257
#> min values : 0.0, 0.0, 0.0, 0.0, 0, 0.0, ...
260258
#> max values : 910.1, 824.3, 727.3, 741.3, 1100, 2512.6, ...

vignettes/getCRUCLdata.Rmd.orig

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ vignette: >
1212
%\VignetteDepends{terra}
1313
%\VignetteDepends{ggplot2}
1414
%\VignetteDepends{viridis}
15+
%\VignetteDepends{data.table}
1516
---
1617

1718
```{r setup, include=FALSE}
@@ -71,7 +72,7 @@ The arguments for selecting the climatology elements for importing are:
7172
- **dsn** *For `create_CRU_stack()`* and *`create_CRU_df()`* only.
7273
Local file path where CRU CL v. 2.0 .dat.gz files are located.
7374

74-
### Creating tidy data frames for use in R
75+
### Creating data frames for use in R
7576

7677
The `get_CRU_df()` function automates the download process and creates data frames of the climatology elements.
7778

@@ -94,19 +95,19 @@ CRU_data <- get_CRU_df(pre = TRUE,
9495
CRU_data
9596
```
9697

97-
Perhaps you only need one or two elements, it is easy to create a tidy data frame of mean temperature only.
98+
Perhaps you only need one or two elements, it is easy to create a data frame of mean temperature only.
9899

99100
```{r get_t_only, eval=TRUE}
100101
t <- get_CRU_df(tmp = TRUE)
101102

102103
t
103104
```
104105

105-
#### Plotting data from the tidy dataframe
106+
#### Plotting data from the data frame
106107

107108
Now that we have the data, we can plot it easily using _ggplot2_ and the _viridis_ package for the colour scale.
108109

109-
```{r plot_t, eval=TRUE, message=FALSE}
110+
```{r plot_t, eval=TRUE, message=FALSE, fig.cap="Maps of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991."}
110111
library(ggplot2)
111112
library(viridis)
112113

@@ -120,28 +121,29 @@ ggplot(data = t, aes(x = lon, y = lat, fill = tmp)) +
120121

121122
We can also generate a violin plot of the same data to visualise how the temperatures change throughout the year.
122123

123-
```{r violin_plot, eval=TRUE}
124+
```{r violin_plot, eval=TRUE, fig.cap = "Monthly values of global temperatures from CRU CL v. 2.0 climatology covering the Earth's surface from ymin = -60, ymax = 85, xmin = -180, xmax = 180 degrees from 1960 to 1991."}
124125
ggplot(data = t, aes(x = month, y = tmp)) +
125126
geom_violin() +
126127
ylab("Temperature (˚C)") +
127128
labs(title = "Global Monthly Mean Land Surface Temperatures From 1960-1991",
128129
subtitle = "Excludes Antarctica")
129130
```
130131

131-
#### Saving the tidy `data.frame` as a CSV (comma separated values file) locally
132+
#### Saving the `data.frame` as a CSV (comma separated values file) locally
132133

133-
Save the resulting tidy `data.frame` to local disk as a comma separated (CSV)
134+
Save the resulting `data.frame` to local disk as a comma separated (CSV)
134135
file to local disk, using _data.table_'s `fwrite()`.
135136

136137
```{r save_t, eval=FALSE}
138+
library(data.table)
137139
fwrite(x = t, file = "~/CRU_tmp.csv")
138140
```
139141

140142
### Creating terra raster stacks for use in R and saving for use in another GIS
141143

142144
For working with spatial data, _getCRUCLdata_ provides a function that create lists of _terra_ stacks of the data.
143145

144-
The `get_CRU_stack()` functions provide similar functionality to `get_CRU_df()`, but rather than returning a tidy data frame, it returns a list of `terra::rast()` objects for use in an R session.
146+
The `get_CRU_stack()` functions provide similar functionality to `get_CRU_df()`, but rather than returning a data frame, it returns a list of `terra::rast()` objects for use in an R session.
145147

146148
The `get_CRU_stack()` function automates the download process and creates a `terra::rast()` object of the CRU CL v. 2.0 climatology elements.
147149
Illustrated here is creating a `terra::rast()` of all CRU CL v. 2.0 climatology elements available.

0 commit comments

Comments
 (0)