Skip to content

Commit d16ddd7

Browse files
Removing old rd syntax (#191)
this is part of #189 I noticed some old syntax that was not previously checked, so I am creating a separate pull request for it.
1 parent 45a3104 commit d16ddd7

4 files changed

Lines changed: 188 additions & 188 deletions

File tree

R/qenv-join.R

Lines changed: 96 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -7,102 +7,101 @@
77
#' See below for an example.
88
#'
99
#' There are some situations where `join()` cannot be properly performed, such as these three scenarios:
10-
#' \enumerate{
11-
#' \item Both `qenv` objects contain an object of the same name but are not identical. \cr\cr
12-
#' Example:
13-
#' \preformatted{
14-
#' x <- qenv(
15-
#' code = c(mtcars1 = "mtcars1 <- mtcars"),
16-
#' env = list2env(list(mtcars1 = mtcars))
17-
#' )
18-
#' y <- qenv(
19-
#' code = c(mtcars1 = "mtcars1 <- mtcars['wt']"),
20-
#' env = list2env(list(mtcars1 = mtcars['wt']))
21-
#' )
22-
#' z <- join(x, y)
23-
#' # Error message will occur
24-
#' }
25-
#' In this example, `mtcars1` object exists in both `x` and `y` objects but the content are not identical.\cr
26-
#' `mtcars1` in the `x qenv` object has more columns than `mtcars1` in the `y qenv` object (only has one column).
27-
#' \item `join()` will look for identical `@id` values in both `qenv` objects.
28-
#' The index position of these `@id`s must be the same to determine the evaluation order.
29-
#' Otherwise, `join()` will throw an error message.\cr\cr
30-
#' Example:
31-
#' \preformatted{
32-
#' common_q <- qenv(code = "v <- 1", env = list2env(list(v = 1)))
33-
#' x <- eval_code(
34-
#' common_q,
35-
#' "x <- v"
36-
#' )
37-
#' y <- eval_code(
38-
#' common_q,
39-
#' "y <- v"
40-
#' )
41-
#' z <- eval_code(
42-
#' y,
43-
#' "z <- v"
44-
#' )
45-
#' q <- join(x, y)
46-
#' join_q <- join(q, z)
47-
#' # Error message will occur
48-
#'
49-
#' # Check the order of evaluation based on the id slot
50-
#' shared_ids <- intersect(q@id, z@id)
51-
#' match(shared_ids, q@id) # Output: 1 3
52-
#' match(shared_ids, z@id) # Output: 1 2
53-
#' }
54-
#' The error occurs because the index position of identical `@id` between the two objects is not the same.
55-
#' \item The usage of temporary variable in the code expression could cause `join()` to fail. \cr\cr
56-
#' Example:
57-
#' \preformatted{
58-
#' common_q <- qenv()
59-
#' x <- eval_code(
60-
#' common_q,
61-
#' "x <- numeric(0)
62-
#' for (i in 1:2) {
63-
#' x <- c(x, i)
64-
#' }"
65-
#' )
66-
#' y <- eval_code(
67-
#' common_q,
68-
#' "y <- numeric(0)
69-
#' for (i in 1:3) {
70-
#' y <- c(y, i)
71-
#' }"
72-
#' )
73-
#' q <- join(x,y)
74-
#' # Error message will occur
75-
#'
76-
#' # Check the value of temporary variable i in both objects
77-
#' x@env$i # Output: 2
78-
#' y@env$i # Output: 3
79-
#' }
80-
#' `join()` fails to provide a proper result because of the temporary variable `i` exists
81-
#' in both objects but has different value.\cr
82-
#' To fix this, we can set `i <- NULL` in the code expression for both objects.
83-
#' \preformatted{
84-
#' common_q <- qenv()
85-
#' x <- eval_code(
86-
#' common_q,
87-
#' "x <- numeric(0)
88-
#' for (i in 1:2) {
89-
#' x <- c(x, i)
90-
#' }
91-
#' # dummy i variable to fix it
92-
#' i <- NULL"
93-
#' )
94-
#' y <- eval_code(
95-
#' common_q,
96-
#' "y <- numeric(0)
97-
#' for (i in 1:3) {
98-
#' y <- c(y, i)
99-
#' }
100-
#' # dummy i variable to fix it
101-
#' i <- NULL"
102-
#' )
103-
#' q <- join(x,y)
104-
#' }
105-
#' }
10+
#' 1. Both `qenv` objects contain an object of the same name but are not identical.
11+
#'
12+
#' Example:
13+
#'
14+
#' ```r
15+
#' x <- eval_code(qenv(), expression(mtcars1 <- mtcars))
16+
#' y <- eval_code(qenv(), expression(mtcars1 <- mtcars['wt']))
17+
#'
18+
#' z <- join(x, y)
19+
#' # Error message will occur
20+
#' ```
21+
#' In this example, `mtcars1` object exists in both `x` and `y` objects but the content are not identical.
22+
#' `mtcars1` in the `x qenv` object has more columns than `mtcars1` in the `y qenv` object (only has one column).
23+
#'
24+
#' 2. `join()` will look for identical `@id` values in both `qenv` objects.
25+
#' The index position of these `@id`s must be the same to determine the evaluation order.
26+
#' Otherwise, `join()` will throw an error message.
27+
#'
28+
#' Example:
29+
#' ```r
30+
#' common_q <- eval_code(qenv(), expression(v <- 1))
31+
#' x <- eval_code(
32+
#' common_q,
33+
#' "x <- v"
34+
#' )
35+
#' y <- eval_code(
36+
#' common_q,
37+
#' "y <- v"
38+
#' )
39+
#' z <- eval_code(
40+
#' y,
41+
#' "z <- v"
42+
#' )
43+
#' q <- join(x, y)
44+
#' join_q <- join(q, z)
45+
#' # Error message will occur
46+
#'
47+
#' # Check the order of evaluation based on the id slot
48+
#' shared_ids <- intersect(q@id, z@id)
49+
#' match(shared_ids, q@id) # Output: 1 3
50+
#' match(shared_ids, z@id) # Output: 1 2
51+
#' ```
52+
#' The error occurs because the index position of identical `@id` between the two objects is not the same.
53+
#'
54+
#' 3. The usage of temporary variable in the code expression could cause `join()` to fail.
55+
#'
56+
#' Example:
57+
#' ```r
58+
#' common_q <- qenv()
59+
#' x <- eval_code(
60+
#' common_q,
61+
#' "x <- numeric(0)
62+
#' for (i in 1:2) {
63+
#' x <- c(x, i)
64+
#' }"
65+
#' )
66+
#' y <- eval_code(
67+
#' common_q,
68+
#' "y <- numeric(0)
69+
#' for (i in 1:3) {
70+
#' y <- c(y, i)
71+
#' }"
72+
#' )
73+
#' q <- join(x,y)
74+
#' # Error message will occur
75+
#'
76+
#' # Check the value of temporary variable i in both objects
77+
#' x@env$i # Output: 2
78+
#' y@env$i # Output: 3
79+
#' ```
80+
#' `join()` fails to provide a proper result because of the temporary variable `i` exists
81+
#' in both objects but has different value.
82+
#' To fix this, we can set `i <- NULL` in the code expression for both objects.
83+
#' ```r
84+
#' common_q <- qenv()
85+
#' x <- eval_code(
86+
#' common_q,
87+
#' "x <- numeric(0)
88+
#' for (i in 1:2) {
89+
#' x <- c(x, i)
90+
#' }
91+
#' # dummy i variable to fix it
92+
#' i <- NULL"
93+
#' )
94+
#' y <- eval_code(
95+
#' common_q,
96+
#' "y <- numeric(0)
97+
#' for (i in 1:3) {
98+
#' y <- c(y, i)
99+
#' }
100+
#' # dummy i variable to fix it
101+
#' i <- NULL"
102+
#' )
103+
#' q <- join(x,y)
104+
#' ```
106105
#'
107106
#' @param x (`qenv`)
108107
#' @param y (`qenv`)
@@ -167,7 +166,7 @@ setMethod("join", signature = c("qenv.error", "ANY"), function(x, y) {
167166
#' If two `qenv` can be joined
168167
#'
169168
#' Checks if two `qenv` objects can be combined.
170-
#' For more information, please see \code{\link{join}}
169+
#' For more information, please see [`join`]
171170
#' @param x (`qenv`)
172171
#' @param y (`qenv`)
173172
#' @return `TRUE` if able to join or `character` used to print error message.

R/utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#' Suppresses plot display in the IDE by opening a PDF graphics device
22
#'
3-
#' This function opens a PDF graphics device using \code{\link[grDevices]{pdf}} to suppress
3+
#' This function opens a PDF graphics device using [`grDevices::pdf`] to suppress
44
#' the plot display in the IDE. The purpose of this function is to avoid opening graphic devices
55
#' directly in the IDE.
66
#'
77
#' @param x lazy binding which generates the plot(s)
88
#'
9-
#' @details The function uses \code{\link[base]{on.exit}} to ensure that the PDF graphics
10-
#' device is closed (using \code{\link[grDevices]{dev.off}}) when the function exits,
9+
#' @details The function uses [`base::on.exit`] to ensure that the PDF graphics
10+
#' device is closed (using [`grDevices::dev.off`]) when the function exits,
1111
#' regardless of whether it exits normally or due to an error. This is necessary to
1212
#' clean up the graphics device properly and avoid any potential issues.
1313
#'

man/dev_suppress.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)