Skip to content

Commit 547e42d

Browse files
committed
adjusted aes in vignette
1 parent 3544602 commit 547e42d

File tree

8 files changed

+48
-47
lines changed

8 files changed

+48
-47
lines changed

R/frame-calendar.R

+23-23
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#' It allows more flexibility for users to visualise the data in various ways.
1010
#'
1111
#' @param data A data frame or a grouped data frame including a `Date` variable.
12-
#' @param x A variable mapping to time of day. If integer 1 is specified, it
13-
#' simply returns calendar grids on x without transformation.
14-
#' @param y One variable or more mapping to value. If more than one variable,
12+
#' @param x A variable mapping to x axis, for example time of day. If integer 1
13+
#' is specified, it simply returns calendar grids on x without transformation.
14+
#' @param y One variable or more mapping to y axis. If more than one variable,
1515
#' the variables needs to be quoted. If integer 1 is specified, it returns
1616
#' calendar grids on y without transformation.
1717
#' @param date A `Date` variable mapping to dates in the calendar.
@@ -71,11 +71,11 @@
7171
#' x = Time, y = Hourly_Counts, date = Date, sunday = TRUE
7272
#' )
7373
#'
74-
#' p2 <- grped_calendar %>%
74+
#' grped_calendar %>%
7575
#' ggplot(aes(x = .Time, y = .Hourly_Counts, group = Date)) +
7676
#' geom_line() +
7777
#' facet_wrap(~ Sensor_Name, nrow = 2)
78-
#' # prettify(p2, label = "text") not working for group_by
78+
#' # prettify() not working for group_by
7979
#'
8080
#' @export
8181
frame_calendar <- function(
@@ -164,7 +164,7 @@ frame_calendar_ <- function(
164164
# but quo_name() doesn't support LHS
165165
data <- cal_grids %>%
166166
right_join(data, by = c("PANEL" = quo_name(date))) %>%
167-
mutate(!!.date := PANEL)
167+
dplyr::mutate(!!.date := PANEL)
168168

169169
# Define a small multiple width and height
170170
width <- resolution(data$.gx, zero = FALSE) * 0.95
@@ -173,28 +173,28 @@ frame_calendar_ <- function(
173173

174174
if (calendar == "monthly") {
175175
data <- data %>%
176-
group_by(MPANEL) %>%
177-
mutate(
176+
dplyr::group_by(MPANEL) %>%
177+
dplyr::mutate(
178178
.gx = .gx + MCOL * margins,
179179
.gy = .gy - MROW * margins
180180
)
181181
}
182182

183183
data <- ungroup(data) # is.null(scale)
184184
if (scale == "free") {
185-
data <- group_by(data, ROW, COL)
185+
data <- dplyr::group_by(data, ROW, COL)
186186
} else if (scale == "free_wday") {
187187
data <- data %>%
188-
mutate(.day = wday(!!date)) %>%
189-
group_by(.day)
188+
dplyr::mutate(.day = wday(!!date)) %>%
189+
dplyr::group_by(.day)
190190
} else if (scale == "free_mday") {
191191
data <- data %>%
192-
mutate(.day = mday(!!date)) %>%
193-
group_by(.day)
192+
dplyr::mutate(.day = mday(!!date)) %>%
193+
dplyr::group_by(.day)
194194
}
195195

196196
data <- data %>%
197-
mutate(
197+
dplyr::mutate(
198198
.ymax = max(!!!y, na.rm = TRUE),
199199
.ymin = min(!!!y, na.rm = TRUE)
200200
)
@@ -204,30 +204,30 @@ frame_calendar_ <- function(
204204
}
205205
.y <- paste0(".", y[[1]])
206206
data <- data %>%
207-
mutate(
207+
dplyr::mutate(
208208
theta = 2 * pi * normalise(!!x, xmax = max_na(!!x)),
209209
radius = normalise(!!!y, xmax = max_na(!!!y)),
210210
!!.x := .gx + width * radius * sin(theta),
211211
!!.y := .gy + height * radius * cos(theta)
212212
) %>%
213-
select(-c(theta, radius))
213+
dplyr::select(-c(theta, radius))
214214
} else {
215215
fn <- function(x, ymax, ymin) { # temporal function for mutate at
216216
normalise(x, xmax = max_na(ymax), xmin = min_na(ymin)) * height
217217
}
218218
if (possibly_identity(x)) {
219-
data <- mutate(data, .x = .gx)
219+
data <- dplyr::mutate(data, .x = .gx)
220220
} else {
221221
data <- data %>%
222-
mutate(
222+
dplyr::mutate(
223223
!!.x := .gx + normalise(!!x, xmax = max_na(!!x)) * width
224224
)
225225
}
226226
if (possibly_identity(y)) {
227-
data <- mutate(data, .y = .gy)
227+
data <- dplyr::mutate(data, .y = .gy)
228228
} else {
229229
data <- data %>%
230-
mutate_at(
230+
dplyr::mutate_at(
231231
.vars = vars(!!!y),
232232
.funs = funs(zzz = .gy + fn(., .ymax, .ymin))
233233
)
@@ -242,10 +242,10 @@ frame_calendar_ <- function(
242242

243243
data <- data %>%
244244
ungroup() %>%
245-
select(-(ROW:.gy)) %>%
246-
select(-c(.ymax, .ymin))
245+
dplyr::select(-(ROW:.gy)) %>%
246+
dplyr::select(-c(.ymax, .ymin))
247247
if (scale %in% c("free_wday", "free_mday")) {
248-
data <- select(data, -.day) # remove .day variable
248+
data <- dplyr::select(data, -.day) # remove .day variable
249249
}
250250

251251
# rename y's variables

docs/articles/frame-calendar.html

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Loading

docs/reference/frame-calendar-2.png

282 KB
Loading

docs/reference/frame-calendar.html

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/frame-calendar.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)