Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions R/modsem_mplus.R
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,9 @@ cleanupMplusFiles <- function(fprefix) {
}


getMplusFilePrefix <- function(max.iter = 20) {
getMplusFilePrefix <- function(max.iter = 20, base = "mpresults") {
randid <- generateRandomCharId(n=12)
fprefix <- paste0("mplusResults", randid)
fprefix <- paste0(base, randid)

if (!mplusFilePrefixExists(fprefix))
return(fprefix)
Expand All @@ -747,3 +747,12 @@ getMplusFilePrefix <- function(max.iter = 20) {

fprefix
}


generateRandomCharId <- function(n = 36) {
# use only lower letters, as Mplus sometimes seem to convert upper case
# characters in the .inp file to lower characters in the .out file. In
# particular this seems to happen on Mplus 8.11 on Windows
chars <- c(letters, as.character(0:9))
paste0(sample(chars, size = n, replace = TRUE), collapse = "")
}
6 changes: 0 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,3 @@ std1 <- function(v) {

(v - mu) / sigma
}


generateRandomCharId <- function(n = 36) {
chars <- c(letters, LETTERS, as.character(0:9))
paste0(sample(chars, size = n, replace = TRUE), collapse = "")
}
Loading