0

I have an example matrix that looks as follows:

     Unstim Unstim.1 Unstim.2 Unstim.3 Unstim.4
BB100    330      175      576      290      203
BB104    320      194      803      325      211
BB110    274      141      379      351      419
BB112    295      187      512      363      210`

I hope to group the row names into groups for example BB100 and BB104 would be in "SLE" and BB110 BB112 would be in "RA" but without adding a column to the matrix because I hope to put the matrix into the qgraph function. Ideally, the "SLE", "RA" etc. groups would be in a vector that would allow me to run

qgraph(cor(matrix), groups = group)

I'm hoping this would allow me to visualize a correlation matrix with the groups identified.

I'm new to R so sorry if this has been answered but I've been trying to find an answer all day but I just can't seem to find one Thanks in advance

Michael
  • 41
  • 3
  • 2
    don't understand the question, what should groups look like, and how do you plan on making that vector if not allowed to use what is inside the matrix? – Timo Kvamme Aug 27 '15 at 21:37
  • `group <- rep(c("SLE","RA"),each=2)` ?? – jlhoward Aug 28 '15 at 05:33
  • Also, the `qgraph(...)` function (in package `qgraph`), plots a network diagram. Is that really what you want? – jlhoward Aug 28 '15 at 05:34
  • Thanks for the reply jihoward. I believe it is what I want. To be honest I'm a medical student trying to learn bioinformatics and so it's a steep learning curve but I have subjects of different diseases i would like to see the correlation between them based on a set on a set of variables. Im trying to copy what was done in this paper: qgraph: Network Visualizations of Relationships in Psychometric Data Ill try your suggestion tomorrow thanks – Michael Aug 28 '15 at 06:03
  • Thanks for the reply User..: So for the above matrix I would want to manually group each row in the matrix to a group. I would then hopefully be able to call or display the "groupings" so something like this would be displayed: "SLE": BB100, BB104 "RA": BB110, BB112 Hopefully that makes for sense? – Michael Aug 28 '15 at 06:07
  • @jlhoward - I get that your above code will make a repeating list but now if I want to assign the list names to the names in the matrix so if I called on groups I would get something like this: `$SLE [1] BB100 BB104 $RA [1] BB110 BB112` Thanks – Michael Aug 28 '15 at 19:00

0 Answers0