Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Config/Needs/website: cynkra/cynkratemplate
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3.9000
Config/roxygen2/version: 8.0.0.9000
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -558,5 +558,11 @@ importFrom(grDevices,dev.off)
importFrom(grDevices,pdf)
importFrom(methods,getSlots)
importFrom(stats,setNames)
importFrom(utils,capture.output)
importFrom(utils,getFromNamespace)
importFrom(utils,head)
importFrom(utils,methods)
importFrom(utils,packageDescription)
importFrom(utils,tail)
useDynLib("")
useDynLib(constructive)
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/s3-integer64.new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# integer64

Code
construct(bit64::as.integer64(c("-1000", "NA", "100000")))
Condition
Warning in `as.integer64.character()`:
NAs introduced by coercion to integer64 range
Output
bit64::as.integer64(c("-1000", "NA", "100000"))

140 changes: 140 additions & 0 deletions tests/testthat/_snaps/s3-tbl_df.new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# tbl_df

Code
construct(dplyr::band_members)
Output
tibble::tibble(name = c("Mick", "John", "Paul"), band = c("Stones", "Beatles", "Beatles"))
Code
construct(dplyr::band_members, opts_tbl_df("next"))
Output
data.frame(name = c("Mick", "John", "Paul"), band = c("Stones", "Beatles", "Beatles")) |>
structure(class = c("tbl_df", "tbl", "data.frame"))
Code
construct(dplyr::band_members, opts_tbl_df("next"), opts_data.frame("next"))
Output
list(name = c("Mick", "John", "Paul"), band = c("Stones", "Beatles", "Beatles")) |>
structure(class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -3L))
Code
construct(dplyr::band_members, opts_tbl_df(constructor = "tribble"))
Output
tibble::tribble(
~name, ~band,
"Mick", "Stones",
"John", "Beatles",
"Paul", "Beatles",
)
Code
construct(dplyr::band_members, opts_tbl_df(constructor = "tribble", justify = "right"))
Output
tibble::tribble(
~name, ~band,
"Mick", "Stones",
"John", "Beatles",
"Paul", "Beatles",
)
Code
construct(tibble::tibble(a = as.Date("2001-01-01")), opts_tbl_df("tribble"))
Output
tibble::tribble(
~a,
as.Date("2001-01-01"),
)
Code
construct(dplyr::group_by(dplyr::band_members, band))
Output
tibble::tibble(name = c("Mick", "John", "Paul"), band = c("Stones", "Beatles", "Beatles")) |>
dplyr::group_by(band)

# tbl_df with `tribble = TRUE` falls back on tibble() if unsupported cols are found

Code
construct(tibble::tibble(a = 1:2, b = list(3, 4)), opts_tbl_df(constructor = "tribble"))
Output
tibble::tibble(a = 1:2, b = list(3, 4))
Code
construct(tibble::tibble(a = 1:2, b = tibble::tibble(x = 3:4)), opts_tbl_df(
constructor = "tribble"))
Output
tibble::tibble(
a = 1:2,
b = tibble::tribble(
~x,
3L,
4L,
),
)

# recycle in tibbles

Code
construct(tibble::tibble(a = 1:2, b = c(1, 1)))
Output
tibble::tibble(a = 1:2, b = 1)
Code
construct(tibble::tibble(a = c(1, 1), b = c(1, 1)))
Output
tibble::tibble(a = 1, b = 1, .rows = 2L)
Code
construct(tibble::tibble(a = 1:2, b = factor(c("a", "a"))))
Output
tibble::tibble(a = 1:2, b = factor("a"))
Code
construct(tibble::tibble(a = 1:2, b = as.Date(c("2000-01-01", "2000-01-01"))))
Output
tibble::tibble(a = 1:2, b = as.Date("2000-01-01"))

# duplicate names in tibbles

Code
construct(tibble::tibble(a = 1, a = 2, .name_repair = "minimal"))
Output
tibble::tibble(a = 1, a = 2, .name_repair = "minimal")

# non standard names in tibbles

Code
construct(structure(tibble::tibble(1), names = NULL))
Output
list(1) |>
structure(row.names = c(NA, -1L), class = c("tbl_df", "tbl", "data.frame"))
Code
construct(structure(tibble::tibble(1), names = ""))
Output
tibble::tibble(1) |>
structure(names = "")
Code
construct(structure(tibble::tibble(1), names = NA))
Output
tibble::tibble(1) |>
structure(names = NA_character_)
Code
construct(structure(tibble::tibble(1), names = ".rows"))
Output
tibble::tibble(1) |>
structure(names = ".rows")
Code
construct(structure(tibble::tibble(1), names = ".name_repair"))
Output
tibble::tibble(1) |>
structure(names = ".name_repair")
Code
construct(structure(tibble::tibble(1, 2), names = c("a", "")))
Output
tibble::tibble(a = 1, 2) |>
structure(names = c("a", ""))
Code
construct(structure(tibble::tibble(1, 2), names = c("a", NA)))
Output
tibble::tibble(a = 1, 2) |>
structure(names = c("a", NA))
Code
construct(structure(tibble::tibble(1, 2), names = c("a", ".rows")))
Output
tibble::tibble(a = 1, 2) |>
structure(names = c("a", ".rows"))
Code
construct(structure(tibble::tibble(1, 2), names = c("a", ".name_repair")))
Output
tibble::tibble(a = 1, 2) |>
structure(names = c("a", ".name_repair"))