I have a list, and its head is:
$AK
hospital state
NA <NA> <NA>
$AL
hospital state
20 D W MCMILLAN MEMORIAL HOSPITAL AL
$AR
hospital state
20 ARKANSAS METHODIST MEDICAL CENTER AR
$AZ
hospital state
20 JOHN C LINCOLN DEER VALLEY HOSPITAL AZ
$CA
hospital state
20 SHERMAN OAKS HOSPITAL CA
$CO
hospital state
20 SKY RIDGE MEDICAL CENTER CO
I want to merge this list to a matrix, like this:
hospital state
AK <NA> AK
AL D W MCMILLAN MEMORIAL HOSPITAL AL
AR ARKANSAS METHODIST MEDICAL CENTER AR
AZ JOHN C LINCOLN DEER VALLEY HOSPITAL AZ
CA SHERMAN OAKS HOSPITAL CA
CO SKY RIDGE MEDICAL CENTER CO
notice: the first line of the matrix is different from the first item in the list. In the list, the state of the first item is <NA>
, but the state of the first line in the matrix is AK. It is that merge the list's factor and the "hospital" in the list.
What should I do?
And what if I want to merge the items in the list into a matrix?