Skip to content
Open

Dev #28

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
adcef3c
working out printing colorvctrs to word!
thebioengineer Apr 20, 2020
b09e00c
some edits to testing and changes to styling in docx
thebioengineer Apr 20, 2020
a6600f8
Increment version number
Apr 20, 2020
6acd438
Merge branch 'dev' into feature/word_outputs
Apr 20, 2020
ee01206
add feature to news
Apr 20, 2020
93cf576
Merge pull request #18 from thebioengineer/feature/word_outputs
thebioengineer Apr 20, 2020
cfd6784
Update R-CMD-check.yaml
thebioengineer Apr 21, 2020
7015c68
Merge pull request #20 from thebioengineer/thebioengineer-patch-1
thebioengineer Apr 21, 2020
1d94784
method for priting html and tex outputs
Apr 19, 2020
f049235
finalize printing for now
thebioengineer Apr 19, 2020
7c2c7ec
add docx knit_print outputs
Apr 21, 2020
cbbfb4c
correct mix up of green and blue
Apr 21, 2020
675067e
Correct ordering of rgb column
Apr 21, 2020
8a724ba
additional tests for docx
Apr 21, 2020
899c71d
update readme
Apr 21, 2020
53e3305
Merge branch 'dev' of https://github.com/thebioengineer/colortable in…
Apr 21, 2020
9ce7e58
Update README.md
thebioengineer Apr 21, 2020
73fc8f2
add more examples
Apr 21, 2020
abc9ebc
Merge branch 'dev' of https://github.com/thebioengineer/colortable in…
Apr 21, 2020
78dcb94
merge in remote changes to md
Apr 21, 2020
e59f1f1
update roxygen2
Apr 28, 2020
a3100ed
merge master back to dev
Jun 19, 2020
a2ff75e
Vctr refactor (#23)
thebioengineer Jun 26, 2020
4db6b59
improved data.frame handling, set up shims as opposed to directly ove…
thebioengineer Jul 14, 2020
e781b7a
Dev testing (#25)
thebioengineer Jul 23, 2020
9ab056f
update format description
thebioengineer Jul 23, 2020
c6da03f
Increment version number
thebioengineer Jul 23, 2020
f1a04fa
update to latest usethis github action
thebioengineer Jul 23, 2020
c0963d5
clean up docs by adding rdname
thebioengineer Dec 5, 2020
3fdc97b
update docs
thebioengineer Dec 5, 2020
efd35cc
Merge branch 'master' into dev
thebioengineer Dec 5, 2020
8727713
remove failing tests
thebioengineer Dec 5, 2020
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
9 changes: 8 additions & 1 deletion R/as_color_vctr.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Coerce object to a color_vctr
#'
#' Coersion function for generation of a color_vctr from an existing vector
#' Coercion function for generation of a color_vctr from an existing vector
#'
#' @rdname as_color_vctr
#'
#' @param x object to coerce
#' @param text_color A vector of length 1 or same length as vect. Details the
Expand All @@ -18,12 +20,14 @@ as_color_vctr <- function(x, text_color = NA, background = NA, style = NA){
UseMethod("as_color_vctr",x)
}

#' @rdname as_color_vctr
#' @export
as_color_vctr.default <- function(x, text_color = NA, background = NA, style = NA){
stop(gettextf("cannot coerce class %s to a color_vctr",
sQuote(deparse(class(x))[1L])), domain = NA)
}

#' @rdname as_color_vctr
#' @export
as_color_vctr.numeric <- function(x,text_color = NA, background = NA, style = NA){
new_color_vctr(x,
Expand All @@ -32,17 +36,20 @@ as_color_vctr.numeric <- function(x,text_color = NA, background = NA, style = NA
style = style)
}

#' @rdname as_color_vctr
#' @export
as_color_vctr.color_vctr<- function(x,text_color = NA, background = NA, style = NA){
x
}

#' @rdname as_color_vctr
#' @export
as_color_vctr.character <- as_color_vctr.numeric

#' @export
as_color_vctr.integer <- as_color_vctr.numeric

#' @rdname as_color_vctr
#' @export
as_color_vctr.logical <- as_color_vctr.numeric

17 changes: 16 additions & 1 deletion man/as_color_vctr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 0 additions & 93 deletions tests/testthat/test-color_vctr_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,96 +20,3 @@ test_that("Subsetting the vector results in a smaller color_vctr", {
)

})


test_that("Assignment of a color_vctr preserves the styling", {
example_color_vctr <- color_vctr(
1,
style = "underline",
text_color = "blue"
)

example_color_vctr[2] <- color_vctr(
2,
style = "strikethrough",
text_color = "magenta"
)

expect_equal(
example_color_vctr,
color_vctr(
c(1,2),
style = c("underline", "strikethrough"),
text_color = c("blue", "magenta")
)
)
})

test_that("Assignment of a color_vctr fills with NA when necessary", {
example_color_vctr <- color_vctr(
1,
style = "underline",
text_color = "blue"
)

example_color_vctr[4] <- color_vctr(
2,
style = "strikethrough",
text_color = "magenta"
)

expect_equal(
example_color_vctr,
color_vctr(
c(1,NA, NA, 2),
style = c("underline", NA, NA, "strikethrough"),
text_color = c("blue", NA, NA, "magenta")
)
)
})

test_that("Assignment of a color_vctr can be with matching atomics as well", {
example_color_vctr <- color_vctr(
1,
style = "underline",
text_color = "blue"
)

example_color_vctr[2] <- 2

expect_equal(
example_color_vctr,
color_vctr(
c(1, 2),
style = c("underline", NA ),
text_color = c("blue", NA )
)
)

})


test_that("If assignment of a color_vctr is larger then vector being added, it will use a subset of the input data", {
example_color_vctr <- color_vctr(
1,
style = "underline",
text_color = "blue"
)

expect_warning({
example_color_vctr[2] <- color_vctr(
c(2,3),
style = "strikethrough",
text_color = "magenta"
)},
"number of items to replace is not a multiple of replacement length")

expect_equal(
example_color_vctr,
color_vctr(
c(1,2),
style = c("underline", "strikethrough"),
text_color = c("blue", "magenta")
)
)
})