Learn R Programming

jmvReadWrite (version 0.4.14)

transpose_omv: Transpose .omv-files for the statistical spreadsheet 'jamovi' (https://www.jamovi.org)

Description

Transpose .omv-files for the statistical spreadsheet 'jamovi' (https://www.jamovi.org)

Usage

transpose_omv(
  dtaInp = NULL,
  fleOut = "",
  varNme = "",
  usePkg = c("foreign", "haven"),
  selSet = "",
  ...
)

Value

a data frame (only returned if fleOut is empty) where the input data set is transposed

Arguments

dtaInp

Either a data frame or the name of a data file to be read (including the path, if required; "FILENAME.ext"; default: NULL); files can be of any supported file type, see Details below.

fleOut

Name of the data set / file to be written (including the path, if required; "FILE_OUT.omv"; default: ""); if empty, the resulting data frame is returned instead.

varNme

Name of the variables in the output data frame; see Details below

usePkg

Name of the package: "foreign" or "haven" that shall be used to read SPSS, Stata, and SAS files; "foreign" is the default (it is included in base R), but "haven" is newer and more comprehensive; you may have to install using install.packages("haven", dep = TRUE).

selSet

Name of the object / data set that is to be selected from the workspace (only relevant when reading .RData-files which can contain several objects / data sets)

...

Additional arguments passed on to methods; see Details below

Details

  • If varNme empty, the row names of the input data set are used (preceded by "V_" if all row names are numbers); if varNme has length 1, then it is supposed to point to a variable in the input data frame; if varNme has the same length as the number of rows in the input data frame, then the values in varNme are assigned as column names to the output data frame.

  • The ellipsis-parameter (...) can be used to submit arguments / parameters to the functions that are used for reading the data. By clicking on the respective function under “See also”, you can get a more detailed overview over which parameters each of those functions take.

See Also

transpose_omv internally uses the following functions for reading and writing data files in different formats: read_omv() and write_omv() for jamovi-files, utils::read.table() for CSV / TSV files, load() for reading .RData-files, readRDS() for .rds-files, haven::read_sav() or foreign::read.spss() for SPSS-files, haven::read_dta() or foreign::read.dta() for Stata-files, haven::read_sas() for SAS-data-files, and haven::read_xpt() or foreign::read.xport() for SAS-transport-files.

Examples

Run this code
set.seed(1)
tmpDF <- stats::setNames(as.data.frame(matrix(sample(6, 1200, replace = TRUE), nrow = 16)),
                         sprintf("sbj_%03d", seq(75)))
str(tmpDF)
# Data sets that were extracted, e.g., from PsychoPy, may look like this (trials as rows
# and participants as columns, one for each participant, manually assembled / copy-and-pasted).
# However, for analyses, one wants the data set transposed (units / participants as columns)...
nmeOut <- tempfile(fileext = ".omv")
jmvReadWrite::transpose_omv(dtaInp = tmpDF, fleOut = nmeOut)
dtaFrm <- jmvReadWrite::read_omv(nmeOut)
unlink(nmeOut)
str(dtaFrm)
# if no varNme-parameter is given, generic variable names are created (V_...)
jmvReadWrite::transpose_omv(dtaInp = tmpDF, fleOut = nmeOut, varNme = sprintf("Trl_%02d", seq(16)))
dtaFrm <- jmvReadWrite::read_omv(nmeOut)
unlink(nmeOut)
str(dtaFrm)
# alternatively, the character vector with the desired variable names (of the same length as
# the number of rows in tmpDF) may be given, "Trl" can easily be exchanged by the name of your
# questionnaire, experimental conditions, etc.


Run the code above in your browser using DataLab