The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Online version. This guide is also published on ZENTRA Cloud as Working with Your Data in R. This vignette ships with the package for offline use.
Once zc_get_readings() (or zc_sync()) has
given you a data frame of readings, here are the everyday R commands for
looking at it, filtering it, summarising it, and saving it. You need
very little R to be productive — this covers the essentials, with links
to fuller R guides at the end.
Throughout, readings is the tidy data frame returned by
zc_get_readings():
The single most useful habit in R: store a result in a named
object with <-, or it prints once and is
gone.
# Prints once, then lost:
zc_pivot_wider(readings)
# Saved as `wide` — now you can view it, filter it, plot it, or export it:
wide <- zc_pivot_wider(readings)
wideYou choose the name (wide, daily,
air_temp, …). The <- is R’s assignment
arrow: name on the left, value on the right.
readings # a tibble: prints the first 10 rows and the column types
View(readings) # open the RStudio spreadsheet viewer (capital V)
head(readings, 20) # first 20 rows; tail(readings) for the last few
str(readings) # structure: every column and its type
dplyr::glimpse(readings) # a tidy, transposed overview
summary(readings) # quick per-column statistics
dim(readings) # number of rows and columns; nrow() / ncol()
names(readings) # the column namesView() is interactive (RStudio only) — in a script or a
scheduled job use print(), head(), or
str() instead.
readings$column pulls out a single column by name.
Combine that with a few base functions to get your bearings:
The dplyr package (part of the tidyverse) reads almost
like English:
library(dplyr)
# Keep only valid air-temperature readings:
readings |> filter(measurement == "Air Temperature", error_code == 0)
# Highest values first:
readings |> arrange(desc(value))The |> is R’s pipe: it feeds the value on its left
into the function on its right. Base R does the same with square
brackets, if you prefer:
For publication-quality graphics with ggplot2, see the
plotting example in the Getting Started with zentraR
vignette.
# CSV — opens in Excel / Google Sheets, easy to share:
write.csv(readings, "readings.csv", row.names = FALSE)
# RDS — an exact copy of the R object (types preserved); reload with readRDS():
saveRDS(readings, "readings.rds")
readings <- readRDS("readings.rds")For an automated, incremental local archive, use zentraR’s own stores
(zc_store_csv(), zc_store_rds()) with
zc_sync() — see the Scheduling Automatic Syncs
vignette.
These free resources cover R itself, well beyond what you need for zentraR:
dplyr,
ggplot2, RStudio, and more.Related zentraR guides:
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.