0

Background

While analysing some data in a SEM model one can list the indicators that are the most influent to the model fit. This is done with the command modind from the lavaan project. I can filter it to show only the first few. The command looks like:

head(mod_ind[order(mod_ind$mi, decreasing=TRUE), ], 4)

The output would normally look like:

               lhs op rhs group mi mi.scaled epc sepc.lv sepc.all
5760         var12  ~   g     1  0         0   0       0        0
7740         var2   ~   g     1  0         0   0       0        0
5562         var35  ~   g     1  0         0   0       0        0
8598         var7   ~   g     1  0         0   0       0        0

Question

  • How to parse/pipe the name of these variables (var12, var2, var35, var7) into a vector of strings?
lf_araujo
  • 1,991
  • 2
  • 16
  • 39

1 Answers1

0

Rather a simple answer with the help from @chinsoon12:

vector<-head(mod_ind[order(mod_ind$mi, decreasing=TRUE), "lhs"], 4)

To assert:

is.vector(vector)
lf_araujo
  • 1,991
  • 2
  • 16
  • 39