輸入格式鑄造一個數據幀
structure(list(FROM_STOP_ID = c("DEP10001", "DEP10001", "DEP10001",
"DEP10001", "DEP10001", "DEP10001",
"DEP10001", "DEP10001", "DEP10001",
"DEP10001"),
TO_STOP_ID = c("DEP10001", "DEP10022",
"DEP25005", "DEP35024", "DEP45024", "DEP50002",
"STP62369", "STP62829", "STP63844", "STP63889"),
TRAVEL_TIME = c(0, 518, 497, 131, 0, 131, 483, 137,
489, 504)), .Names = c("FROM_STOP_ID", "TO_STOP_ID", "TRAVEL_TIME"
預計outpout格式
從輸入datframe爲rownames,第二列的列名,第三列的值一欄填寫了
structure(list(DEP10001 = 0, DEP10022 = 518, DEP25005 = 497,
DEP35024 = 131, DEP45024 = 0), .Names = c("DEP10001", "DEP10022",
"DEP25005", "DEP35024", "DEP45024"), row.names = "DEP10001", class = "data.frame")
上面的第一個data.frame格式不好,但是'tidyr :: spread(df1,TO_STOP_ID,TRAVEL_TIME)'或者其他任何long到wide的變體。 – alistaire