尝试在 R 中使用 read_xml 函数并获取 0 列表时出现问题?
Issue with trying to use read_xml function in R and getting a List of 0?
我有一个正在处理的 .xml 文件,它看起来有点乱。我正在尝试获取名为“x1”、“y1”、“x2”、“y2”的四列的四列数据框。抱歉,我无法附上 xml 文件,但这里是文本文件。
<Annotations><Annotation LineColor="65535" Name="FDC Trapped Virions" Visible="True"><Regions><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="16440" Y="42581" />
<V X="17551" Y="43082" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="28041" Y="25888" />
<V X="26589" Y="27260" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="19110" Y="38302" />
<V X="21249" Y="40753" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="23028" Y="42522" />
<V X="23123" Y="42599" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22976" Y="42708" /><V X="22757" Y="42887" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23558" Y="42484" /><V X="23721" Y="42606" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22961" Y="42271" /><V X="23444" Y="42386" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23060" Y="42271" /><V X="22996" Y="42272" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21947" Y="39056" /><V X="23348" Y="42087" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24004" Y="40133" /><V X="25263" Y="41124" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25678" Y="41862" /><V X="24448" Y="42590" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14668" Y="40287" /><V X="16114" Y="41775" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19976" Y="35409" /><V X="20904" Y="36360" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16749" Y="5769" /><V X="18349" Y="3931" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34051" Y="12508" /><V X="35188" Y="14257" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28586" Y="26884" /><V X="29515" Y="28033" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32435" Y="28428" /><V X="30660" Y="29686" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25603" Y="30962" /><V X="23740" Y="32947" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28447" Y="31272" /><V X="27083" Y="32656" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20946" Y="28045" /><V X="22977" Y="29813" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18883" Y="29315" /><V X="20849" Y="31447" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16421" Y="31841" /><V X="17797" Y="32779" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14239" Y="31023" /><V X="12268" Y="32999" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9663" Y="31862" /><V X="11457" Y="33707" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15470" Y="33838" /><V X="11733" Y="37421" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15964" Y="33484" /><V X="17525" Y="35232" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19496" Y="36918" /><V X="17670" Y="34748" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25991" Y="36387" /><V X="25894" Y="36509" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32331" Y="27816" /><V X="30170" Y="26401" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23609" Y="7193" /><V X="22215" Y="5383" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15526" Y="8223" /><V X="13126" Y="5591" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28877" Y="29243" /><V X="27841" Y="30211" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9495" Y="14902" /><V X="10153" Y="14420" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32377" Y="6860" /><V X="32957" Y="7433" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34351" Y="18777" /><V X="34433" Y="18852" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14285" Y="18413" /><V X="14740" Y="18827" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23148" Y="42457" /><V X="23258" Y="42535" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28929" Y="15818" /><V X="31223" Y="14027" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="31282" Y="25152" /><V X="31600" Y="25512" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="17897" Y="21487" /><V X="19025" Y="22769" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11864" Y="20505" /><V X="12627" Y="20135" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16815" Y="15989" /><V X="16975" Y="16117" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18462" Y="16084" /><V X="18563" Y="16175" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18436" Y="14845" /><V X="18542" Y="14973" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7645" Y="13613" /><V X="8017" Y="13857" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34140" Y="8448" /><V X="34808" Y="9073" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22546" Y="9423" /><V X="23700" Y="8338" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4008" Y="8351" /><V X="4485" Y="8759" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="2933" Y="7552" /><V X="3347" Y="8516" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22605" Y="10989" /><V X="23421" Y="12163" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32192" Y="25395" /><V X="32855" Y="26195" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9898" Y="10354" /><V X="7200" Y="13036" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="30280" Y="6392" /><V X="31546" Y="7021" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="12355" Y="5094" /><V X="10510" Y="6597" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="31601" Y="18654" /><V X="34245" Y="20625" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34368" Y="18610" /><V X="31509" Y="17700" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19599" Y="15361" /><V X="20105" Y="14758" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21789" Y="15275" /><V X="20568" Y="16164" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22603" Y="15287" /><V X="24756" Y="17410" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26976" Y="16607" /><V X="28925" Y="18884" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25582" Y="18149" /><V X="26594" Y="19791" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23309" Y="19337" /><V X="21980" Y="21459" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="29829" Y="20838" /><V X="32133" Y="22734" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28081" Y="23679" /><V X="30597" Y="25516" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26900" Y="21435" /><V X="28666" Y="23408" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25330" Y="21452" /><V X="23984" Y="22628" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28853" Y="25746" /><V X="29051" Y="26017" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10982" Y="15264" /><V X="12371" Y="16423" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7625" Y="20844" /><V X="8422" Y="21437" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13009" Y="16651" /><V X="13134" Y="16752" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="17710" Y="5895" /><V X="20198" Y="7844" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16912" Y="8828" /><V X="17768" Y="9582" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15237" Y="9600" /><V X="16587" Y="10875" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13721" Y="9432" /><V X="14754" Y="10531" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14251" Y="13814" /><V X="13219" Y="12559" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15749" Y="13172" /><V X="16652" Y="14596" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18568" Y="12521" /><V X="17182" Y="13229" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20614" Y="11209" /><V X="19024" Y="13424" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26578" Y="11284" /><V X="27183" Y="11982" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20704" Y="14442" /><V X="22321" Y="12858" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26143" Y="13797" /><V X="23992" Y="11744" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10100" Y="13132" /><V X="11406" Y="11888" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25232" Y="35567" /><V X="23471" Y="37180" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23144" Y="38144" /><V X="21435" Y="36458" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5937" Y="3425" /><V X="7294" Y="4782" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21415" Y="24057" /><V X="23925" Y="26065" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14323" Y="23568" /><V X="13247" Y="24136" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7801" Y="6061" /><V X="9188" Y="7288" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3408" Y="6678" /><V X="3111" Y="6896" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4170" Y="5502" /><V X="3706" Y="5938" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4091" Y="4645" /><V X="4454" Y="5168" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5194" Y="3513" /><V X="4483" Y="4333" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4623" Y="9759" /><V X="2834" Y="9090" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3838" Y="11542" /><V X="2962" Y="10326" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3180" Y="12692" /><V X="3516" Y="12900" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3631" Y="14134" /><V X="4130" Y="14445" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4531" Y="15175" /><V X="4136" Y="14877" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="6183" Y="14376" /><V X="7875" Y="15752" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28153" Y="14802" /><V X="26351" Y="13601" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="33735" Y="16845" /><V X="31278" Y="15600" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34656" Y="18759" /><V X="35191" Y="20520" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21301" Y="40071" /><V X="21534" Y="40278" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="12879" Y="22907" /><V X="13393" Y="23403" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10647" Y="23265" /><V X="11775" Y="24297" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5315" Y="26558" /><V X="7479" Y="29352" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11035" Y="26545" /><V X="12301" Y="27375" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13769" Y="24993" /><V X="15841" Y="26653" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13968" Y="28323" /><V X="15353" Y="26371" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21104" Y="27769" /><V X="19811" Y="26972" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25021" Y="26127" /><V X="22720" Y="28469" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26512" Y="27296" /><V X="25562" Y="27896" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15669" Y="20254" /><V X="17069" Y="22367" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25782" Y="16507" /><V X="25982" Y="16660" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20452" Y="16642" /><V X="21341" Y="17323" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14718" Y="24319" /><V X="11495" Y="25571" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="8393" Y="32180" /><V X="8034" Y="31427" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24431" Y="37943" /><V X="26067" Y="39645" /></Vertices></Region></Regions></Annotation><Annotation LineColor="65280" Name="vRNA+" Visible="True"><Regions>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24447" Y="40561" /><V X="24490" Y="40588" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="30046" Y="26794" /><V X="30126" Y="26864" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24801" Y="42127" /><V X="24828" Y="42146" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13505" Y="27614" /><V X="13583" Y="27678" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15482" Y="26810" /><V X="15549" Y="26859" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11079" Y="23643" /><V X="11158" Y="23577" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="8232" Y="32097" /><V X="8272" Y="32136" /></Vertices></Region></Regions></Annotation><Annotation LineColor="255"
但是,我得到的 vertices_42350 列表为 0。这是我用来尝试此操作的代码:
library(xml2) # Loads the xml2 package
library(tidyverse) # Loads the tidyverse package
vertices_42350 <- read_xml("42350.xml") %>% xml_find_all('.//Vertices') # calling xml file from directory
xy_data_42350 <-
tibble(
x1 = vertices_42350 %>% xml_find_all('./*[1]') %>% xml_attr('X'),
y1 = vertices_42350 %>% xml_find_all('./*[1]') %>% xml_attr('Y'),
x2 = vertices_42350 %>% xml_find_all('./*[2]') %>% xml_attr('X'),
y2 = vertices_42350 %>% xml_find_all('./*[2]') %>% xml_attr('Y')
) %>%
mutate_all(as.integer)
有什么想法吗?我认为这与 xml_find_all?
有关
这是一个将所有 X&Y 值分成两半并重新组合成最终数据帧的解决方案。
#find all of the attributes values (list of x & y values)
values <-file %>% xml_find_all(".//Vertices") %>% xml_find_all(".//V") %>% xml_attrs()
#bind into a data frame and alternate naming rows
values <-bind_rows(values) %>%
mutate_all(as.integer)
rownumbers <- rep(c(1,2), (nrow(values)/2))
#split by the odd and even rows and bind into final answer
#make unique column names
answer <- cbind(values[rownumbers==1,], values[rownumbers==2,])
names(answer) <- make.names(names(answer), unique = TRUE)
我有一个正在处理的 .xml 文件,它看起来有点乱。我正在尝试获取名为“x1”、“y1”、“x2”、“y2”的四列的四列数据框。抱歉,我无法附上 xml 文件,但这里是文本文件。
<Annotations><Annotation LineColor="65535" Name="FDC Trapped Virions" Visible="True"><Regions><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="16440" Y="42581" />
<V X="17551" Y="43082" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="28041" Y="25888" />
<V X="26589" Y="27260" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="19110" Y="38302" />
<V X="21249" Y="40753" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0">
<Vertices>
<V X="23028" Y="42522" />
<V X="23123" Y="42599" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22976" Y="42708" /><V X="22757" Y="42887" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23558" Y="42484" /><V X="23721" Y="42606" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22961" Y="42271" /><V X="23444" Y="42386" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23060" Y="42271" /><V X="22996" Y="42272" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21947" Y="39056" /><V X="23348" Y="42087" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24004" Y="40133" /><V X="25263" Y="41124" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25678" Y="41862" /><V X="24448" Y="42590" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14668" Y="40287" /><V X="16114" Y="41775" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19976" Y="35409" /><V X="20904" Y="36360" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16749" Y="5769" /><V X="18349" Y="3931" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34051" Y="12508" /><V X="35188" Y="14257" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28586" Y="26884" /><V X="29515" Y="28033" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32435" Y="28428" /><V X="30660" Y="29686" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25603" Y="30962" /><V X="23740" Y="32947" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28447" Y="31272" /><V X="27083" Y="32656" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20946" Y="28045" /><V X="22977" Y="29813" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18883" Y="29315" /><V X="20849" Y="31447" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16421" Y="31841" /><V X="17797" Y="32779" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14239" Y="31023" /><V X="12268" Y="32999" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9663" Y="31862" /><V X="11457" Y="33707" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15470" Y="33838" /><V X="11733" Y="37421" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15964" Y="33484" /><V X="17525" Y="35232" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19496" Y="36918" /><V X="17670" Y="34748" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25991" Y="36387" /><V X="25894" Y="36509" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32331" Y="27816" /><V X="30170" Y="26401" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23609" Y="7193" /><V X="22215" Y="5383" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15526" Y="8223" /><V X="13126" Y="5591" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28877" Y="29243" /><V X="27841" Y="30211" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9495" Y="14902" /><V X="10153" Y="14420" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32377" Y="6860" /><V X="32957" Y="7433" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34351" Y="18777" /><V X="34433" Y="18852" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14285" Y="18413" /><V X="14740" Y="18827" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23148" Y="42457" /><V X="23258" Y="42535" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28929" Y="15818" /><V X="31223" Y="14027" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="31282" Y="25152" /><V X="31600" Y="25512" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="17897" Y="21487" /><V X="19025" Y="22769" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11864" Y="20505" /><V X="12627" Y="20135" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16815" Y="15989" /><V X="16975" Y="16117" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18462" Y="16084" /><V X="18563" Y="16175" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18436" Y="14845" /><V X="18542" Y="14973" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7645" Y="13613" /><V X="8017" Y="13857" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34140" Y="8448" /><V X="34808" Y="9073" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22546" Y="9423" /><V X="23700" Y="8338" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4008" Y="8351" /><V X="4485" Y="8759" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="2933" Y="7552" /><V X="3347" Y="8516" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22605" Y="10989" /><V X="23421" Y="12163" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="32192" Y="25395" /><V X="32855" Y="26195" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="9898" Y="10354" /><V X="7200" Y="13036" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="30280" Y="6392" /><V X="31546" Y="7021" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="12355" Y="5094" /><V X="10510" Y="6597" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="31601" Y="18654" /><V X="34245" Y="20625" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34368" Y="18610" /><V X="31509" Y="17700" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="19599" Y="15361" /><V X="20105" Y="14758" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21789" Y="15275" /><V X="20568" Y="16164" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="22603" Y="15287" /><V X="24756" Y="17410" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26976" Y="16607" /><V X="28925" Y="18884" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25582" Y="18149" /><V X="26594" Y="19791" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23309" Y="19337" /><V X="21980" Y="21459" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="29829" Y="20838" /><V X="32133" Y="22734" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28081" Y="23679" /><V X="30597" Y="25516" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26900" Y="21435" /><V X="28666" Y="23408" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25330" Y="21452" /><V X="23984" Y="22628" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28853" Y="25746" /><V X="29051" Y="26017" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10982" Y="15264" /><V X="12371" Y="16423" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7625" Y="20844" /><V X="8422" Y="21437" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13009" Y="16651" /><V X="13134" Y="16752" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="17710" Y="5895" /><V X="20198" Y="7844" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="16912" Y="8828" /><V X="17768" Y="9582" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15237" Y="9600" /><V X="16587" Y="10875" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13721" Y="9432" /><V X="14754" Y="10531" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14251" Y="13814" /><V X="13219" Y="12559" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15749" Y="13172" /><V X="16652" Y="14596" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="18568" Y="12521" /><V X="17182" Y="13229" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20614" Y="11209" /><V X="19024" Y="13424" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26578" Y="11284" /><V X="27183" Y="11982" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20704" Y="14442" /><V X="22321" Y="12858" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26143" Y="13797" /><V X="23992" Y="11744" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10100" Y="13132" /><V X="11406" Y="11888" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25232" Y="35567" /><V X="23471" Y="37180" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="23144" Y="38144" /><V X="21435" Y="36458" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5937" Y="3425" /><V X="7294" Y="4782" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21415" Y="24057" /><V X="23925" Y="26065" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14323" Y="23568" /><V X="13247" Y="24136" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="7801" Y="6061" /><V X="9188" Y="7288" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3408" Y="6678" /><V X="3111" Y="6896" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4170" Y="5502" /><V X="3706" Y="5938" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4091" Y="4645" /><V X="4454" Y="5168" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5194" Y="3513" /><V X="4483" Y="4333" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4623" Y="9759" /><V X="2834" Y="9090" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3838" Y="11542" /><V X="2962" Y="10326" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3180" Y="12692" /><V X="3516" Y="12900" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="3631" Y="14134" /><V X="4130" Y="14445" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="4531" Y="15175" /><V X="4136" Y="14877" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="6183" Y="14376" /><V X="7875" Y="15752" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="28153" Y="14802" /><V X="26351" Y="13601" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="33735" Y="16845" /><V X="31278" Y="15600" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="34656" Y="18759" /><V X="35191" Y="20520" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21301" Y="40071" /><V X="21534" Y="40278" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="12879" Y="22907" /><V X="13393" Y="23403" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="10647" Y="23265" /><V X="11775" Y="24297" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="5315" Y="26558" /><V X="7479" Y="29352" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11035" Y="26545" /><V X="12301" Y="27375" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13769" Y="24993" /><V X="15841" Y="26653" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13968" Y="28323" /><V X="15353" Y="26371" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="21104" Y="27769" /><V X="19811" Y="26972" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25021" Y="26127" /><V X="22720" Y="28469" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="26512" Y="27296" /><V X="25562" Y="27896" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15669" Y="20254" /><V X="17069" Y="22367" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="25782" Y="16507" /><V X="25982" Y="16660" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="20452" Y="16642" /><V X="21341" Y="17323" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="14718" Y="24319" /><V X="11495" Y="25571" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="8393" Y="32180" /><V X="8034" Y="31427" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24431" Y="37943" /><V X="26067" Y="39645" /></Vertices></Region></Regions></Annotation><Annotation LineColor="65280" Name="vRNA+" Visible="True"><Regions>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24447" Y="40561" /><V X="24490" Y="40588" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="30046" Y="26794" /><V X="30126" Y="26864" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="24801" Y="42127" /><V X="24828" Y="42146" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="13505" Y="27614" /><V X="13583" Y="27678" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="15482" Y="26810" /><V X="15549" Y="26859" /></Vertices></Region>
<Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="11079" Y="23643" /><V X="11158" Y="23577" /></Vertices></Region><Region Type="Rectangle" HasEndcaps="0" NegativeROA="0"><Vertices><V X="8232" Y="32097" /><V X="8272" Y="32136" /></Vertices></Region></Regions></Annotation><Annotation LineColor="255"
但是,我得到的 vertices_42350 列表为 0。这是我用来尝试此操作的代码:
library(xml2) # Loads the xml2 package
library(tidyverse) # Loads the tidyverse package
vertices_42350 <- read_xml("42350.xml") %>% xml_find_all('.//Vertices') # calling xml file from directory
xy_data_42350 <-
tibble(
x1 = vertices_42350 %>% xml_find_all('./*[1]') %>% xml_attr('X'),
y1 = vertices_42350 %>% xml_find_all('./*[1]') %>% xml_attr('Y'),
x2 = vertices_42350 %>% xml_find_all('./*[2]') %>% xml_attr('X'),
y2 = vertices_42350 %>% xml_find_all('./*[2]') %>% xml_attr('Y')
) %>%
mutate_all(as.integer)
有什么想法吗?我认为这与 xml_find_all?
有关这是一个将所有 X&Y 值分成两半并重新组合成最终数据帧的解决方案。
#find all of the attributes values (list of x & y values)
values <-file %>% xml_find_all(".//Vertices") %>% xml_find_all(".//V") %>% xml_attrs()
#bind into a data frame and alternate naming rows
values <-bind_rows(values) %>%
mutate_all(as.integer)
rownumbers <- rep(c(1,2), (nrow(values)/2))
#split by the odd and even rows and bind into final answer
#make unique column names
answer <- cbind(values[rownumbers==1,], values[rownumbers==2,])
names(answer) <- make.names(names(answer), unique = TRUE)