Skip to content

Commit

Permalink
Changed the title suffix to a title name in rtnDta and jmvOpn
Browse files Browse the repository at this point in the history
  • Loading branch information
sjentsch committed Aug 26, 2023
1 parent 4bf1327 commit fbcf201
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion R/arrange_cols_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ arrange_cols_omv <- function(dtaInp = NULL, fleOut = "", varOrd = c(), varMve =
dtaFrm <- setAtt(setdiff(names(attMem), c("names", "row.names", "class", "fltLst")), attMem, dtaFrm)

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_arr_cols", psvAnl = psvAnl, dtaInp = dtaInp, ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_arr_cols"), psvAnl = psvAnl, dtaInp = dtaInp, ...)
}
2 changes: 1 addition & 1 deletion R/describe_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe_omv <- function(dtaInp = NULL, fleOut = "", dtaTtl = c(), dtaDsc = c(),
status = 3, index = 1, title = "Results", hasTitle = TRUE)

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_desc", wrtPtB = TRUE, ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_desc"), wrtPtB = TRUE, ...)
}

# create HTML from the list-version of dtaDsc
Expand Down
16 changes: 11 additions & 5 deletions R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ inp2DF <- function(dtaInp = NULL, minDF = 1, maxDF = 1, usePkg = c("foreign", "h
# - open the data frame in a new session (only in jamovi, and if fleOut is an empty character vector)
# - return the data frame (in R in any case, or in jamovi if fleOut is NULL)
# NB: this makes opening the data frame in a new session the default, if in jamovi
rtnDta <- function(dtaFrm = NULL, fleOut = "", sfxTtl = "", wrtPtB = FALSE, psvAnl = FALSE, dtaInp = NULL, ...) {
rtnDta <- function(dtaFrm = NULL, fleOut = "", dtaTtl = "", wrtPtB = FALSE, psvAnl = FALSE, dtaInp = NULL, ...) {
if (!is.null(fleOut) && nzchar(fleOut[1])) {
fleOut <- fmtFlO(fleOut[1])
write_omv(dtaFrm = dtaFrm, fleOut = fleOut, wrtPtB = wrtPtB, ...)
Expand All @@ -372,7 +372,7 @@ rtnDta <- function(dtaFrm = NULL, fleOut = "", sfxTtl = "", wrtPtB = FALSE, psvA
return()
} else if (isJmv() && is.character(fleOut)) {
if (psvAnl) warning("psvAnl is only possible if fleOut is a file name (analyses are not stored in data frames, only in the jamovi files).")
jmvOpn(dtaFrm, sfxTtl = sfxTtl)
jmvOpn(dtaFrm, dtaTtl = dtaTtl)
return()
} else {
if (psvAnl) warning("psvAnl is only possible if fleOut is a file name (analyses are not stored in data frames, only in the jamovi files).")
Expand Down Expand Up @@ -472,7 +472,7 @@ jmvAtt <- function(dtaFrm = NULL) {
dtaFrm
}

jmvOpn <- function(dtaFrm = NULL, sfxTtl = "") {
jmvOpn <- function(dtaFrm = NULL, dtaTtl = "") {
# on both Windows and Linux, jamovi is in the path, and, hence,
# Sys.which should give the full location
jmvEXE <- Sys.which("jamovi")
Expand All @@ -496,8 +496,7 @@ jmvOpn <- function(dtaFrm = NULL, sfxTtl = "") {
if (nzchar(jmvEXE) && file.exists(jmvEXE)) {
tmpOut <- tempfile(fileext = ".omv")
jmvReadWrite::write_omv(dtaFrm, fleOut = tmpOut)
# TO-DO: replace Dataset with the name of the current data set
system2(jmvEXE, args = paste0(" --temp --title=\"", "Dataset", sfxTtl, "\" ", tmpOut), stderr = TRUE, stdout = TRUE)
system2(jmvEXE, args = paste0(" --temp --title=\"", dtaTtl, "\" ", tmpOut), stderr = TRUE, stdout = TRUE)
} else {
stop(sprintf("The position of the jamovi executable could not be determined or it was not found at the determined position. Determined position: %s", jmvEXE))
}
Expand All @@ -511,3 +510,10 @@ jmvPth <- function(inpPth = "", strTgt = "", bfrTgt = TRUE) {
return()
}
}

jmvTtl <- function(sfxTtl = "") {
# return empty string when not inside jamove (then the title is irrelevant)
if (!isJmv()) return("")
# TO-DO: replace Dataset with the name of the current data set (once this is implemented)
return(paste0("Dataset", sfxTtl))
}
2 changes: 1 addition & 1 deletion R/long2wide_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ long2wide_omv <- function(dtaInp = NULL, fleOut = "", varTgt = c(), varExc = c()
if (!any(duplicated(dtaFrm[[varID]]))) attr(dtaFrm[[varID]], "jmv-id") <- TRUE

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_wide", ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_wide"), ...)
}

aggDta <- function(dtaFrm = NULL, varAgg = "", varID = c(), varTme = c(), varExc = c(), varTgt = c()) {
Expand Down
2 changes: 1 addition & 1 deletion R/merge_cols_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ merge_cols_omv <- function(dtaInp = NULL, fleOut = "", typMrg = c("outer", "inne
}

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_mrg_cols", psvAnl = psvAnl, dtaInp = dtaInp, ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_mrg_cols"), psvAnl = psvAnl, dtaInp = dtaInp, ...)
}

chkByV <- function(varBy = list(), dtaFrm = NULL) {
Expand Down
2 changes: 1 addition & 1 deletion R/merge_rows_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ merge_rows_omv <- function(dtaInp = NULL, fleOut = "", typMrg = c("all", "common
dtaFrm <- srtFrm(dtaFrm, varSrt)

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_mrg_rows", ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_mrg_rows"), ...)
}

addCol <- function(dtaFrm = NULL, varNme = c(), varTyp = c()) {
Expand Down
2 changes: 1 addition & 1 deletion R/replace_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ replace_omv <- function(dtaInp = NULL, fleOut = "", rplLst = list(), whlTrm = TR
}

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_rplc", psvAnl = psvAnl, dtaInp = dtaInp, ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_rplc"), psvAnl = psvAnl, dtaInp = dtaInp, ...)
}
2 changes: 1 addition & 1 deletion R/sort_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sort_omv <- function(dtaInp = NULL, fleOut = "", varSrt = c(), psvAnl = FALSE, u
dtaFrm <- srtFrm(dtaFrm, varSrt)

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_sort", psvAnl = psvAnl, dtaInp = dtaInp, ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_sort"), psvAnl = psvAnl, dtaInp = dtaInp, ...)
}

srtFrm <- function(dtaFrm = NULL, varSrt = c()) {
Expand Down
2 changes: 1 addition & 1 deletion R/transpose_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ transpose_omv <- function(dtaInp = NULL, fleOut = "", varNme = "", usePkg = c("f
row.names(dtaFrm) <- NULL

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_xpsd", ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_xpsd"), ...)
}
2 changes: 1 addition & 1 deletion R/wide2long_omv.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ wide2long_omv <- function(dtaInp = NULL, fleOut = "", varLst = c(), varExc = c()
dtaFrm <- rmvID(dtaFrm, varID, hasID)

# rtnDta in globals.R (unified function to either write the data frame, open it in a new jamovi session or return it)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, sfxTtl = "_Long", ...)
rtnDta(dtaFrm = dtaFrm, fleOut = fleOut, dtaTtl = jmvTtl("_Long"), ...)
}

ordCol <- function(varNme = c(), dtaNmV = c(), varID = c(), varLst = c()) {
Expand Down

0 comments on commit fbcf201

Please sign in to comment.