if (FALSE) {
library(jmvReadWrite)
fleOMV <- system.file("extdata", "AlbumSales.omv", package = "jmvReadWrite")
fleTmp <- paste0(tempfile(), ".omv")
sort_omv(fleInp = fleOMV, fleOut = fleTmp, varSrt = "Image")
dtaFrm <- read_omv(fleInp = fleTmp)
cat(dtaFrm$Image)
# shows that the variable "Image" is sorted in ascending order
cat(is.unsorted(dtaFrm$Image))
# is.unsorted (which checks for whether the variable is NOT sorted) returns FALSE
sort_omv(fleInp = fleOMV, fleOut = fleTmp, varSrt = "-Image")
# variables can also be sorted in descending order by preceding them with "-"
dtaFrm <- read_omv(fleInp = fleTmp)
cat(dtaFrm$Image)
# shows that the variable "Image" is now sorted in descending order
cat(is.unsorted(dtaFrm$Image))
# this first returns TRUE (the variable is not in ascending order, i.e., unsorted)
cat(is.unsorted(-dtaFrm$Image))
# if the sign of the variable is changed, it returns FALSE (i.e., the variable is
# NOT unsorted)
unlink(fleTmp)
}
Run the code above in your browser using DataLab