Ho un file documento XML. La parte del file è simile al seguente:come creare un frame di dati R da un file xml
-<attr>
<attrlabl>COUNTY</attrlabl>
<attrdef>County abbreviation</attrdef>
<attrtype>Text</attrtype>
<attwidth>1</attwidth>
<atnumdec>0</atnumdec>
-<attrdomv>
-<edom>
<edomv>C</edomv>
<edomvd>Clackamas County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>M</edomv>
<edomvd>Multnomah County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>W</edomv>
<edomvd>Washington County</edomvd>
<edomvds/>
</edom>
</attrdomv>
</attr>
Da questo file XML, voglio creare una cornice di dati R con le colonne di attrlabl, attrdef, attrtype e attrdomv. Si noti che la colonna attrdomv dovrebbe includere tutti i livelli per la variabile category. La cornice di dati dovrebbe essere simile a questo:
attrlabl attrdef attrtype attrdomv
COUNTY County abbreviation Text C Clackamas County; M Multnomah County; W Washington County
Ho un codice incompleto come questo:
doc <- xmlParse("taxlots.shp.xml")
dataDictionary <- xmlToDataFrame(getNodeSet(doc,"//attrlabl"))
La prego di completare il mio codice R? Apprezzo qualsiasi aiuto!
puoi fornire un file xml valido per favore? – agstudy
@agstudy: potresti dirmi come inviare il mio file xml? – POTENZA
non è possibile qui, ma è possibile utilizzare un servizio di upload di file come SkyDrive e postare il collegamento file – agstudy