将时间列从字符变量更改为r中的时间变量?

时间:2018-09-13 11:39:13

标签: r

我创建了一个数据框DF。

  private List<MainActivity_App> getInstalledApps() {
    List<MainActivity_App> temp = new ArrayList<>();

    List<ApplicationInfo> packs = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
    ArrayList<ApplicationInfo> applistTemp = new ArrayList<>();
    for (ApplicationInfo info : packs) {
        try {
            if (packageManager.getLaunchIntentForPackage(info.packageName) != null) {
                applistTemp.add(info);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    chosenAppsList=new ArrayList<>();
    String s=settings.getString("chosenApps","");
    for (int i = 0; i < applistTemp.size(); i++) {
        ApplicationInfo info = applistTemp.get(i);

        String appPackageName = info.packageName;
        String appName="";
        Drawable icon=null;
        boolean select=false;
        if (s.contains(appPackageName)) {
            appName = info.loadLabel(getPackageManager()).toString();
            icon = info.loadIcon(getPackageManager());
            select = true;
        }
        MainActivity_App newApp=new MainActivity_App(appPackageName, appName, icon, 0, select);
        temp.add(newApp);
    }

    return temp;
}

R将“时间”列查看为字符列表。如何将“时间”列识别为时间列表?

我通常使用以下代码;

time <- c("10:00", "11:00", "12:00", "13:00")

temperature <- c("15", "16", "17", "18")

DF <- data.frame(time, temperature)

但是,在这种情况下,时间列不包含秒,因此该代码段不起作用。

1 个答案:

答案 0 :(得分:1)

paste0(time,":00")添加宝贵的时间。