Skip to content

Commit

Permalink
Changed as() into an implementation based upon base R as...
Browse files Browse the repository at this point in the history
  • Loading branch information
sjentsch committed Aug 2, 2023
1 parent afb7af8 commit f5ab7a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/replace_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ replace_omv <- function(dtaInp = NULL, fleOut = "", rplLst = list(), whlTrm = TR
if (rplLst[[j]][1] %in% levels(dtaFrm[[srcNme[i]]])) levels(dtaFrm[[srcNme[i]]]) <- gsub(rplLst[[j]][1], rplLst[[j]][2], levels(dtaFrm[[srcNme[i]]]))
} else if (is.numeric(dtaFrm[[srcNme[i]]]) || is.character(dtaFrm[[srcNme[i]]])) {
srcSel <- srcClm(dtaFrm[[srcNme[i]]], as.character(rplLst[[j]][1]), whlTrm)
if (any(srcSel)) dtaFrm[srcSel, srcNme[i]] <- methods::as(rplLst[[j]][2], typClm)
if (any(srcSel)) {
dtaFrm[srcSel, srcNme[i]] <- ifelse(identical(class(rplLst[[j]][2]), typClm),
rplLst[[j]][2],
eval(parse(text = paste0("as.", typClm, "(rplLst[[j]][2])"))))
}
}
# other variable types are already caught by jmvAtt() above
}
Expand Down

0 comments on commit f5ab7a6

Please sign in to comment.