0
我有以下數據集作爲源:沒有R中所示酒吧ggplot甘特圖
structure(list(JobName = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = ("ATLAS_Admin_DeployClientDatabase", "ATLAS_Admin_ParseMasterCubeDatabase", ATLAS_Admin_xBackup_DeleteOldTable", "BDC_DatabaseMaintenanceJob_ALL_DATABASES", collection_set_1_noncached_collect_and_upload", "CoreX_SAP_B23_dreprecated", CoreXBI_ETL_1014_01Stage", "CoreXBI_ETL_1014_02DWH_Cube", "CoreXBI_ETL_1114_02DWH_Cube", "CoreXBI_ETL_1294_B23", CoreXBI_ETL_AutoTest", "Cycle_Log", "Delphi DEV Load", "Delphi DEV Monthly", mdw_purge_data_[Z_MAS_MDW]", "QA_CoreXBI_ETL_1010", "QA_CoreXBI_ETL_1294", Shrink_the_Logs", "SSIS Server Maintenance Job", "syspolicy_purge_history", sysutility_get_cache_tables_data_into_aggregate_tables_daily", "sysutility_get_cache_tables_data_into_aggregate_tables_hourly", "sysutility_get_views_data_into_cache_tables", "Z_MAS_ADMIN_ALRS", "Z_MAS_ADMIN_Backup_AMOTables", "Z_MAS_ADMIN_Check_Cube_Space", "Z_MAS_ADMIN_Check_Disk_Space", "Z_MAS_ADMIN_Extract_Job_History", "Z_MAS_ADMIN_Monitoring", "Z_MAS_MaintenancePlan.weekly_bak_clean", "Z_MICE_System_Database_Backup_weekly"), class = "factor"), RunDateTime = tructure(c(1478788776, 1479292645, 1479307979, 1479292220, 1479307916, 479314398), class = c("POSIXct", "POSIXt"), tzone = ""), StartWeekday = tructure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", "Monday", Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = "factor"), tartTime = structure(c(-2209108824, -2209123355, -2209108021, -2209123780, 2209108084, -2209101602), class = c("POSIXct", "POSIXt"), tzone = ""), ndRunDateTime = structure(c(1478790159, 1479294190, 1479309546, 1479292284, 479307977, 1479314459), class = c("POSIXct", "POSIXt"), tzone = ""), ndWeekday = structure(c(5L, 7L, 7L, 7L, 7L, 7L), .Label = c("Friday", Monday", "Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = factor"), EndTime = structure(c(-2209107441, -2209121810, -2209106454, 2209123716, -2209108023, -2209101541), class = c("POSIXct", "POSIXt"), tzone "")), .Names = c("JobName", "RunDateTime", "StartWeekday", StartTime", "EndRunDateTime", "EndWeekday", "EndTime"), row.names = c(NA, L), class = "data.frame")
現在我用下面的腳本來創建一個甘特圖出來的數據應該給我不同的工作的持續時間在時間軸上。
library(reshape2)
vars <- c("RunDateTime", "EndRunDateTime", "StartTime", "EndTime")
dataset[vars] <- lapply(dataset[vars], as.POSIXct, format = "%Y-%m-%dT%H:%M:%S")
df <- with(dataset, data.frame(name = JobName, start = RunDateTime, end = EndRunDateTime))
mdfr <- melt(df, measure.vars = c("start", "end"))
library(ggplot2)
ggplot(mdfr, aes(x = value, y = name, color = variable))
geom_line(size = 6)
xlab(NULL)
ylab(NULL)
我的問題是,我得到與x軸在y軸JobNames和DateTime是否圖表,但它沒有價值或酒吧。
任何想法,這是什麼?
編輯:接下來的問題是,現在,它與最後的結束時間連接最早開始時間...
哦!我不知道我必須使用額外的「+」,因爲IDE在每行的開頭顯示爲灰色。 – Talvien