Skip to content

Commit

Permalink
remove use of |> from R/as.R
Browse files Browse the repository at this point in the history
  • Loading branch information
dewittpe committed Nov 6, 2024
1 parent c7d3f9c commit 2baec63
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: REDCapExporter
Title: Automated Construction of R Data Packages from REDCap Projects
Version: 0.3.0
Version: 0.3.1
Authors@R: c(
person(given = "Peter", family = "DeWitt", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6391-0795"))
)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 0.3.1

## Bug fix
* modify code in R/as.R to not use the `|>` operator so that the package code
has more backward compatibility.

# Version 0.3.0

* updated source code to address deprecated roxygen2 documentation tags
Expand Down
36 changes: 23 additions & 13 deletions R/as.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,31 @@ read_text <- function(x) {
out <- utils::read.csv(text = x, colClasses = "character")

if ("forms_export" %in% names(out)) {

f <-
strsplit(out[["forms"]], ",") |>
lapply(strsplit, ":") |>
lapply(lapply, function(x) stats::setNames(data.frame(x[2]), x[1])) |>
lapply(as.data.frame) |>
do.call(rbind, args = _)
# the following is great for R 4.2 or newer, need to make this work for older versions of R too.
#f <-
# strsplit(out[["forms"]], ",") |>
# lapply(strsplit, ":") |>
# lapply(lapply, function(x) stats::setNames(data.frame(x[2]), x[1])) |>
# lapply(as.data.frame) |>
# do.call(rbind, args = _)
f <- strsplit(out[["forms"]], ",")
f <- lapply(f, strsplit, ":")
f <- lapply(f, lapply, function(x) stats::setNames(data.frame(x[2]), x[1]))
f <- lapply(f, as.data.frame)
f <- do.call(rbind, args = f)
names(f) <- paste0("forms.", names(f))

fe <-
strsplit(out[["forms_export"]], ",") |>
lapply(strsplit, ":") |>
lapply(lapply, function(x) stats::setNames(data.frame(x[2]), x[1])) |>
lapply(as.data.frame) |>
do.call(rbind, args = _)
#fe <-
# strsplit(out[["forms_export"]], ",") |>
# lapply(strsplit, ":") |>
# lapply(lapply, function(x) stats::setNames(data.frame(x[2]), x[1])) |>
# lapply(as.data.frame) |>
# do.call(rbind, args = _)
fe <- strsplit(out[["forms_export"]], ",")
fe <- lapply(fe, strsplit, ":")
fe <- lapply(fe, lapply, function(x) stats::setNames(data.frame(x[2]), x[1]))
fe <- lapply(fe, as.data.frame)
fe <- do.call(rbind, args = fe)
names(fe) <- paste0("forms_export.", names(fe))

out[["forms"]] <- NULL
Expand Down

0 comments on commit 2baec63

Please sign in to comment.