R/syntax-get_data.R

Defines functions mplus_data.mplus.model mplus_data.mplusObject mplus_data

# @title Get data from model object
# @description Extracts data from an object for which a method exists.
# @param x An object for which a method exists.
# @param ... Additional arguments passed to and from functions.
# @return A \code{data.frame}.
# @examples
# \dontrun{
# if(interactive()){
#  #EXAMPLE1
#  }
# }
# @rdname mplus_data
# @export
mplus_data <- function(x, ...){
  UseMethod("mplus_data", x)
}

# @method mplus_data mplusObject
# @export
mplus_data.mplusObject <- function(x, ...){
  Args <- as.list(match.call()[-1])
  Args$x <- x$results
  do.call(mplus_data, Args)
}

# @method mplus_data mplus.model
# @export
#' @importFrom utils read.table
mplus_data.mplus.model <- function(x, ...){
  df <- read.table(x$input$data$file, stringsAsFactors = FALSE)
  names(df) <- mplus_expand_names(x$input$variable$names) #strsplit(x$input$variable$names, split = "\\s+")[[1]]
  df
}

Try the tidySEM package in your browser

Any scripts or data that you put into this service are public.

tidySEM documentation built on Oct. 25, 2023, 1:06 a.m.