to_list_of_lists {semptools}R Documentation

Convert a named vector to a list of lists

Description

Convert a named vector to a list of lists, to be used by various functions in semptools.

Usage

to_list_of_lists(input, name1 = NULL, name2 = NULL, name3 = NULL)

Arguments

input

A named vector

name1

The name for the first element in the list-in-list. Default is NULL.

name2

The name for the second element in the list-in-list. Defaultis NULL.

name3

The name for the third element in the list-in-list. Default is NULL. If this argument is not NULL, the names of the vector elements will be split using lavaan syntax (by calling lavaan::lavParseModelString()), and the right-hand side (rhs) and left-hand side (lhs) of each element will be assigned to name1 and name2, respectively.

Details

This function is not to be used by users, but to be used internally by other functions of semptools.

Value

A list of lists.

Examples

x <- c("x1 ~~ x2" = -1, "x4 ~ x1" = 1)
to_list_of_lists(x, name1 = "from", name2 = "to", name3 = "new_curve")
#list(list(from = "x1", to = "x2", new_curve = -1),
#     list(from = "x1", to = "x4", new_curve =  1))

y <- c(x1 = 0, x2 = 180, x3 = 140, x4 = 140)
to_list_of_lists(y, name1 = "node", name2 = "rotate")
#list(list(node = "x1", rotate =   0),
#     list(node = "x2", rotate = 180),
#     list(node = "x3", rotate = 140),
#     list(node = "x4", rotate = 140))


[Package semptools version 0.2.10 Index]