Skip to content

Commit

Permalink
Merge pull request #63 from EcologyR/blankcells_corr
Browse files Browse the repository at this point in the history
amendments to allow empty cells
closes #62
  • Loading branch information
iramosgutierrez committed Jan 17, 2024
2 parents 1d91df4 + 66e10ea commit bc40ee6
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# labeleR 0.1.2

* Function `fill_NAs_df` created and implemented in functions to allow empty cells (#62)

# labeleR 0.1.1

* Function `create_tinylabel` renamed as `create_tiny_label` for consistency (#57).
Expand Down
1 change: 1 addition & 0 deletions R/badge.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ create_badge <- function(data = NULL,

if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions R/certificate_attendance.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ create_attendance_certificate <- function(

if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions R/certificate_participation.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ create_participation_certificate <- function(

if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions R/collection_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ create_collection_label <- function(data = NULL,

if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions R/herbarium.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ create_herbarium_label <- function(data = data,
}
if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions R/tiny_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ create_tiny_label <- function(data = NULL,

if (!(all(class(data) == "data.frame"))) {data <- as.data.frame(data)}
if (!inherits(data, "data.frame")) {stop("The 'data' object must be a data frame.")}
data <- fill_NAs_df(data)

if (is.null(path)) {stop("A folder path must be specified.")}
if (!file.exists(path)) {
Expand Down
15 changes: 15 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ check_latex_columns <- function(df= NULL, columns= NULL){
return(df)
}

na2blank <- function(x){
x[is.na(x)] <- "~"
return(x)}

fill_NAs_df <- function(df = NULL){
cols <- colnames(df)
rows <- rownames(df)
mat <- matrix(apply(df, 2, na2blank), nrow = length(rows), ncol=length(cols))
df <- as.data.frame(mat)
colnames(df) <- cols
rownames(df) <- rows

return(df)
}


#### Check columns in data

Expand Down
4 changes: 4 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Comments for labeleR 0.1.2 submission

* We have included a new function to allow columns which have some empty cells.

## Comments for labeleR 0.1.1 submission

* We have amended the description section within the DESCRIPTION file.
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-badge.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

data <- data.frame(Names = c("Pippin", "Frodo"),
Affil = "Home", "Casa")
Affil = c("Home", NA))
path <- tempdir()

test_that("PDF file is created in the provided path", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-herbarium_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data <- data.frame("ID"= "1",
"Assistants"= "Person2, Person3",
"Family"= "Canellae",
"Taxon"= "Trorgssionis sp.1",
"Author"= "L.",
"Author"= NA,
"det"= "Person1",
"Det_date"= "1/1/2001",
"life_form"= "shrub",
Expand Down

0 comments on commit bc40ee6

Please sign in to comment.