R数据转换,聚合

时间:2017-06-07 16:30:47

标签: r dplyr transformation reshape reshape2

我试图转换以下数据框:



<table border = 1>
<tr>
  <td>id</td>
  <td>code</td>
  <td>status</td>
</tr>
<tr>
  <td>123</td>
  <td>041</td>
  <td>C</td>
</tr>
<tr>
  <td>123</td>
  <td>056</td>
  <td>NC</td>
</tr>
<tr>
  <td>123</td>
  <td>036</td>
  <td>NC</td>
</tr>

<tr>
  <td>456</td>
  <td>075</td>
  <td>C</td>
</tr>
<tr>
  <td>456</td>
  <td>059</td>
  <td>C</td>
</tr>
<tr>
  <td>456</td>
  <td>039</td>
  <td>NC</td>
</tr>
<tr>
  <td>456</td>
  <td>021</td>
  <td>NC</td>
</tr>
</table>
&#13;
&#13;
&#13;

喜欢如下:(在某种程度上我试图在状态字段上转动我的结果,但是鉴于代码是字符串,我想连接属于该状态的代码。

&#13;
&#13;
<table border=1>
  <tr>
    <td>id</td>
    <td>c</td>
    <td>nc</td>
  </tr>
  <tr>
    <td>123</td>
    <td>041</td>
    <td>056;036</td>
  </tr>
   <tr>
    <td>456</td>
    <td>075;059</td>
    <td>039;021</td>
  </tr>
</table>
&#13;
&#13;
&#13;

我也试过使用reshape / reshape2,但是,我没有获得成功。任何人都可以建议任何可以提供帮助的方法

1 个答案:

答案 0 :(得分:-1)

能够弄清楚。 使用dyplr包。

public class CheckRooted {
    public static boolean isRooted() {

        // get from build info
        String buildTags = android.os.Build.TAGS;
        if (buildTags != null && buildTags.contains("test-keys")) {
            return true;
        }

        // check if /system/app/Superuser.apk is present
        try {
            File file = new File("/system/app/Superuser.apk");
            if (file.exists()) {
                return true;
            }
        } catch (Exception e1) {
            // ignore
        }

        // try executing commands
        return canExecuteCommand("su");
    }

    // executes a command on the system
    private static boolean canExecuteCommand(String command) {
        boolean executedSuccesfully;
        try {
            Runtime.getRuntime().exec(command);
            executedSuccesfully = true;
        } catch (Exception e) {
            executedSuccesfully = false;
        }

        return executedSuccesfully;
    }
}

谢谢!