将键值列表转换为数据帧

时间:2017-11-27 11:18:01

标签: r list dataframe

我在R中有一个名为country的键/值列表:

print(country)
$CAM
[1] 5

$TJK
[1] 1

$SEN
[1] 7

密钥是国家/地区的名称,而值是该国家/地区的值。

我想将此列表转换为数据帧,如:

  country  occurence
0 CAM      5
0 TJK      1
0 SEN      7

感谢和问候

1 个答案:

答案 0 :(得分:6)

您可以取消列表并堆叠输入列表:

      <properties>
        <maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
        <maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>             
        <sonar.jacoco.reportPaths>${project.basedir}/../target/</sonar.jacoco.reportPaths>
        <argLine>-Xmx256m -XX:MaxPermSize=200m</argLine>
      </properties>
        ...
<build>
<plugins>
  <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco-maven-plugin.version}</version>
    <configuration>
      <append>true</append>
    </configuration>
    <executions>
      <execution>
        <id>agent-for-ut</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>${project.basedir}/../target/jacoco-ut.exec</destFile>
        </configuration>
      </execution>
      <execution>
        <id>agent-for-it</id>
        <goals>
          <goal>prepare-agent-integration</goal>
        </goals>
        <configuration>
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
      </execution>
      <execution>
        <id>jacoco-site</id>
        <phase>verify</phase>
        <goals>
          <goal>report</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${maven-failsafe-plugin.version}</version>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <configuration>
      <trimStackTrace>false</trimStackTrace>
    </configuration>
  </plugin>
</plugins>
</build>