I am parsing XML-TEI file. Following this explanation for different length of vectors, I have this script:
cat_xmlID <- getNodeSet(doc, "//ns:category/@xml:id", ns)
cat_xmlID
role=unlist(cat_xmlID[27:29])
context=unlist(cat_xmlID[9:25])
sphere=unlist(cat_xmlID[4:7])
sex=unlist(cat_xmlID[49:50])
n <- max(length(context), length(role), length(sphere), length(sex))
length(context) <-n
length(role) <-n
length(sphere) <-n
length(sex) <-n
catTab_ObjV=cbind(role, context, sphere, sex)
catTab_ObjV
Result:
role context sphere sex
id "active" "ritual" "inside" "male_Sx"
id "passive" "battle" "outside" "female_Sx"
id "both_active" "singleCombat" "unknown_S" NA
NA "prayer" "B_ctx_S" NA
NA "assembly" NA NA
NA "feast" NA NA
NA "wedding" NA NA
NA "burial" NA NA
NA "seduction" NA NA
NA "meeting" NA NA
NA "complaint" NA NA
NA "lawsuit" NA NA
NA "threat" NA NA
NA "revenge" NA NA
NA "visit" NA NA
NA "unknown_C" NA NA
NA "B_ctx_C" NA NA
Of course, I have a lot of NAs. I didn't understand the explanation on how to get rid of NAs in the above-mentioned post and in several other posts — none give a relevant explanation for NA for cbind
function.
I must say I am a beginner in R...
Can you help me? In advance, thank you.