Skip to content

Commit

Permalink
Merge pull request #60 from EcologyR/paco-review
Browse files Browse the repository at this point in the history
Paco review
  • Loading branch information
iramosgutierrez authored Jan 17, 2024
2 parents cfdff6b + 104eac6 commit 21e4efb
Show file tree
Hide file tree
Showing 23 changed files with 244 additions and 1,366 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# labeleR 0.1.1

* Functions names renamed
* Function `create_tinylabel` renamed as `create_tiny_label` for consistency (#57).
* Keep user parameters unchanged
* Description amended

Expand Down
22 changes: 11 additions & 11 deletions R/badge.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
#'
#' @examplesIf interactive()
#' create_badge(
#' data = badges.table,
#' path = "labeleR_output",
#' filename = NULL,
#' event = "INTERNATIONAL CONFERENCE OF MUGGLEOLOGY",
#' name.column = "List",
#' affiliation.column = "Affiliation",
#' lpic = NULL,
#' rpic = NULL)
#' data = badges.table,
#' path = "labeleR_output",
#' filename = NULL,
#' event = "INTERNATIONAL CONFERENCE OF MUGGLEOLOGY",
#' name.column = "List",
#' affiliation.column = "Affiliation",
#' lpic = NULL,
#' rpic = NULL)

create_badge <- function(data = NULL,
path = NULL,
Expand All @@ -52,7 +52,7 @@ create_badge <- function(data = NULL,
stop("Please provide a data.frame or tibble.")
}

if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand All @@ -72,11 +72,11 @@ create_badge <- function(data = NULL,
}

check_column_in_df(data, name.column)
data[,name.column]<- check_latex(data, name.column)
data[,name.column] <- check_latex(data, name.column)

if (!is.null(affiliation.column)) {
check_column_in_df(data, affiliation.column)
data[,affiliation.column]<- check_latex(data, affiliation.column)
data[,affiliation.column] <- check_latex(data, affiliation.column)
}
if (is.null(affiliation.column)) {
affiliation.column <- ""
Expand Down
30 changes: 15 additions & 15 deletions R/certificate_attendance.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
#' @examplesIf interactive()
#'
#' create_attendance_certificate(
#' data = attendance.table,
#' path = "labeleR_output",
#' language = "English",
#' name.column = "Names",
#' type = "class",
#' title = "Potions Class",
#' date = "01/01/2021",
#' hours = 200,
#' freetext = "organised by {\\bf Hogwarts School year 1992-1993}",
#' signer = "A.P.W.B. Dumbledore",
#' signer.role = "School Headmaster",
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL,
#' data = attendance.table,
#' path = "labeleR_output",
#' language = "English",
#' name.column = "Names",
#' type = "class",
#' title = "Potions Class",
#' date = "01/01/2021",
#' hours = 200,
#' freetext = "organised by {\\bf Hogwarts School year 1992-1993}",
#' signer = "A.P.W.B. Dumbledore",
#' signer.role = "School Headmaster",
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL,
#' )


Expand Down Expand Up @@ -79,7 +79,7 @@ create_attendance_certificate <- function(
stop("A data.frame must be provided.")
}

if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand Down
34 changes: 17 additions & 17 deletions R/certificate_participation.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@
#' @examplesIf interactive()
#
#' create_participation_certificate(
#' data = participation.table,
#' path = "labeleR_output",
#' language = "Spanish",
#' name.column = "Name",
#' affiliation.column = "House",
#' comm.type.column = "Comm.type",
#' title.column = "Title",
#' date.column = "Date",
#' type = "online seminar",
#' event = "Hogwarts School of Witchcraft and Wizardry",
#' freetext = "which lasted 2 hours",
#' signer = "A.P.W.B. Dumbledore",
#' signer.role = "School Headmaster",
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL
#' data = participation.table,
#' path = "labeleR_output",
#' language = "Spanish",
#' name.column = "Name",
#' affiliation.column = "House",
#' comm.type.column = "Comm.type",
#' title.column = "Title",
#' date.column = "Date",
#' type = "online seminar",
#' event = "Hogwarts School of Witchcraft and Wizardry",
#' freetext = "which lasted 2 hours",
#' signer = "A.P.W.B. Dumbledore",
#' signer.role = "School Headmaster",
#' lpic = NULL,
#' rpic = NULL,
#' signature.pic = NULL
#' )

create_participation_certificate <- function(
Expand Down Expand Up @@ -89,7 +89,7 @@ create_participation_certificate <- function(
stop("A data.frame must be provided.")
}

if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand Down
18 changes: 9 additions & 9 deletions R/collection_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
#' @examplesIf interactive()
#'
#' create_collection_label(
#' data = label.table,
#' path = "labeleR_output",
#' qr = "QR_code",
#' field1.column = "field1",
#' field2.column = "field2",
#' field3.column = "field3",
#' field4.column = "field6",
#' field5.column = "field7"
#' data = label.table,
#' path = "labeleR_output",
#' qr = "QR_code",
#' field1.column = "field1",
#' field2.column = "field2",
#' field3.column = "field3",
#' field4.column = "field6",
#' field5.column = "field7"
#' )

create_collection_label <- function(data = NULL,
Expand All @@ -66,7 +66,7 @@ create_collection_label <- function(data = NULL,
stop("Please provide a data.frame or tibble.")
}

if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand Down
44 changes: 22 additions & 22 deletions R/herbarium.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@
#' @examplesIf interactive()
#'
#' create_herbarium_label (
#' data = herbarium.table,
#' path = "labeleR_output",
#' title = "Magical flora of the British Isles",
#' subtitle = "Project: Eliminating plant blindness in Hogwarts students",
#' qr = "QR_code",
#' family.column ="Family",
#' taxon.column = "Taxon",
#' author.column = "Author",
#' det.column = "det",
#' date.det.column = "Det_date",
#' location.column = "Location",
#' latitude.column = "Latitude",
#' longitude.column = "Longitude",
#' elevation.column = "Elevation",
#' field1.column = "life_form",
#' field3.column = "Height",
#' collector.column = "Collector",
#' collection.column = "Collection_number",
#' assistants.column = "Assistants",
#' date.column = "Date"
#' data = herbarium.table,
#' path = "labeleR_output",
#' title = "Magical flora of the British Isles",
#' subtitle = "Project: Eliminating plant blindness in Hogwarts students",
#' qr = "QR_code",
#' family.column ="Family",
#' taxon.column = "Taxon",
#' author.column = "Author",
#' det.column = "det",
#' date.det.column = "Det_date",
#' location.column = "Location",
#' latitude.column = "Latitude",
#' longitude.column = "Longitude",
#' elevation.column = "Elevation",
#' field1.column = "life_form",
#' field3.column = "Height",
#' collector.column = "Collector",
#' collection.column = "Collection_number",
#' assistants.column = "Assistants",
#' date.column = "Date"
#' )

create_herbarium_label <- function(data = data,
Expand Down Expand Up @@ -104,7 +104,7 @@ create_herbarium_label <- function(data = data,
if (is.null(data)) {
stop("Please provide a data.frame or tibble.")
}
if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand Down Expand Up @@ -204,7 +204,7 @@ create_herbarium_label <- function(data = data,
collection.column ,
assistants.column ,
date.column )
arguments <- arguments[arguments!=""]
arguments <- arguments[arguments != ""]

data <- check_latex_columns(data, arguments)

Expand Down
20 changes: 10 additions & 10 deletions R/tiny_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
#'
#' @examplesIf interactive()
#' create_tiny_label(
#' data = tiny.table,
#' qr = "QR_code",
#' path = "labeleR_output",
#' field1.column = "field1",
#' field2.column = "field2",
#' field3.column = "field3",
#' field4.column = "field4",
#' field5.column = "field5"
#' data = tiny.table,
#' qr = "QR_code",
#' path = "labeleR_output",
#' field1.column = "field1",
#' field2.column = "field2",
#' field3.column = "field3",
#' field4.column = "field4",
#' field5.column = "field5"
#' )
#'

Expand All @@ -58,7 +58,7 @@ create_tiny_label <- function(data = NULL,
stop("Please provide a data.frame or tibble.")
}

if(!(all(class(data)=="data.frame"))){data <- as.data.frame(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.")}

if (is.null(path)) {stop("A folder path must be specified.")}
Expand Down Expand Up @@ -105,7 +105,7 @@ create_tiny_label <- function(data = NULL,
field5.column <- check_column_or_create_empty_char(data, field5.column)

arguments <- c(field1.column,field2.column,field3.column,field4.column,field5.column)
arguments <- arguments[arguments!=""]
arguments <- arguments[arguments != ""]

data <- check_latex_columns(data, arguments)

Expand Down
4 changes: 2 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ check_latex<- function(df = NULL, column=NULL){
}

check_latex_columns <- function(df= NULL, columns= NULL){
for(column in columns){
for (column in columns) {
df[,column] <- check_latex(df, column)
}
return(df)
Expand Down Expand Up @@ -71,7 +71,7 @@ use_image <- function(image = NULL, name = NULL, folder = NULL) {
on.exit(suppressWarnings(graphics::par(oldpar)))

grDevices::png(file.path(folder, paste0(name, ".png")), 150, 150, "px")
graphics::par(bg="transparent")
graphics::par(bg = "transparent")
graphics::plot.new()
grDevices::dev.off()
}
Expand Down
24 changes: 12 additions & 12 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ create_attendance_certificate(
freetext = "taught by Professor S. Snape",
signer = "A.P.W.B. Dumbledore",
signer.role = "School Headmaster",
rpic=system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic=system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
signature.pic=system.file("rmarkdown/pictures/dumbledore.png", package = "labeleR")
rpic = system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic = system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
signature.pic = system.file("rmarkdown/pictures/dumbledore.png", package = "labeleR")
)
```
Expand Down Expand Up @@ -229,9 +229,9 @@ create_participation_certificate(
freetext = "organized by Hogwarts School of Magic and Wizardry",
signer = "A.P.W.B. Dumbledore",
signer.role = "School Headmaster",
rpic=system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic=system.file("rmarkdown/pictures/MinMagic.png", package = "labeleR"),
signature.pic=system.file("rmarkdown/pictures/dumbledore.png", package = "labeleR")
rpic = system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic = system.file("rmarkdown/pictures/MinMagic.png", package = "labeleR"),
signature.pic = system.file("rmarkdown/pictures/dumbledore.png", package = "labeleR")
)
```

Expand Down Expand Up @@ -271,8 +271,8 @@ create_badge(
event = "INTERNATIONAL CONFERENCE OF MUGGLEOLOGY",
name.column = "List",
affiliation.column = "Affiliation",
rpic=system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic=system.file("rmarkdown/pictures/minMagic.png", package = "labeleR")
rpic = system.file("rmarkdown/pictures/Hogwarts_logo.png", package = "labeleR"),
lpic = system.file("rmarkdown/pictures/MinMagic.png", package = "labeleR")
)
```

Expand Down Expand Up @@ -310,7 +310,7 @@ create_herbarium_label(
data = herbarium.table,
path = "labeleR_output",
filename = "herbarium_labels",
qr="QR_code",
qr = "QR_code",
title ="Magical flora of the British Isles" ,
subtitle = "Project: Eliminating plant blindness in Hogwarts students",
family.column = "Family",
Expand Down Expand Up @@ -366,7 +366,7 @@ create_collection_label(
data = label.table,
path = "labeleR_output",
filename = "labels",
qr="QR_code",
qr = "QR_code",
field1.column = "field1",
field2.column = "field2",
field3.column = "field3",
Expand Down Expand Up @@ -402,12 +402,12 @@ per sheet" in the printer's options.
#### Tinylabels example:

Here, tinylabels are created for typical collections stored in boxes, so
a normal collection label would be to big.
a normal collection label would be too big.

```{r tinylabels, eval=FALSE}
create_tiny_label(
data = tiny.table,
qr="QR_code",
qr = "QR_code",
path = "labeleR_output",
filename = "tinylabels",
field1.column ="field2",
Expand Down
Loading

0 comments on commit 21e4efb

Please sign in to comment.