Skip to content

Commit

Permalink
Adjust strsplit in long2wide_omv and wide2long_omv in order to permit…
Browse files Browse the repository at this point in the history
… having “.” as varSep
  • Loading branch information
sjentsch committed Dec 7, 2023
1 parent 78c76f3 commit 7933605
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/long2wide_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ rstLbl <- function(dtaFrm = NULL, lstLbl = list(), varTgt = c(), varTme = c(), v
if (crrNme %in% names(dtaFrm)) {
attr(dtaFrm[[crrNme]], "jmv-desc") <- lstLbl$orgLbl[[crrNme]]
} else if (crrNme %in% lstLbl$orgTgt) {
splTgt <- strsplit(varTgt, varSep)
splTgt <- strsplit(varTgt, gsub("\\.", "\\\\.", varSep))
for (i in seq_along(splTgt)) {
if (crrNme %in% splTgt[[i]]) {
attr(dtaFrm[[varTgt[i]]], "jmv-desc") <-
Expand Down
2 changes: 1 addition & 1 deletion R/wide2long_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ wide2long_omv <- function(dtaInp = NULL, fleOut = "", varLst = c(), varExc = c()
if (varOrd) varLst <- sort(varLst)
# use varSep to split the variable names in varLst
if (nzchar(varSep)) {
varSpl <- strsplit(varLst, varSep)
varSpl <- strsplit(varLst, gsub("\\.", "\\\\.", varSep))
lngSpl <- unique(unlist(lapply(varSpl, length)))
if (length(lngSpl) != 1) {
stop(sprintf("The variable names in varLst need to have the same structure, i.e., the same number of separators within all variable names:\n%s\n\n",
Expand Down

0 comments on commit 7933605

Please sign in to comment.