我在这里搜索过,我无法找到如何根据属性过滤xml.我有这个xml:
<?xml version="1.0" encoding="utf-8"?>
<document>
<document_head>
<title>This is the title</title>
<version>This is the title</version>
</document_head>
<document_body>
<paragraph id="AXD">
<text>
This is a text that should be in the result
</text>
<properties>
<size>13px</size>
<color>#000000</color>
</properties>
<author>Current user</author>
</paragraph>
<paragraph id="SFI">
<properties>
<text>
This is some other text that should not be in there
</text>
</properties>
</paragraph>
<paragraph id="SFA">
<author>Some random guy</author>
</paragraph>
<paragraph id="ARG">
This doesn't mean anything.
</paragraph>
<paragraph id="RRR">
This does, hence should be in there.
</paragraph>
</document_body>
</document> …
Run Code Online (Sandbox Code Playgroud) 我有一个使用XML文件构建的data.frame,现在我想对其值进行计数和求和,比如SQL中的count和sum.
这是data.frame的外观:
msgDataSource msgFileSource processDate msgNumRows
1 source1 Quarter 2015-01-30 30
2 source1 Month 2015-01-30 15
3 source1 Month 2015-01-30 20
4 source1 Year 2015-01-30 1
5 source2 Quarter 2015-01-30 30
6 source3 Quarter 2015-01-30 15
7 source1 Year 2015-02-01 80
8 source2 Year 2015-02-01 90
9 source1 Quarter 2015-02-01 5
10 source2 Quarter 2015-03-15 9
11 source3 Quarter 2015-03-15 14
Run Code Online (Sandbox Code Playgroud)
这就是我需要的
processDate msgFileSource msgDataSource sumDataSources countDataSources
1: 2015-01-30 Month source1 35 2
2: 2015-01-30 Quarter source1 30 1
3: …
Run Code Online (Sandbox Code Playgroud)