我在做作业/作业时遇到了问题,如果有人愿意提供帮助,我将不胜感激您的专业知识:)
我有一个名为 raceIDs 的文件(看起来像这样):
> raceIDs
[1] "GER" "SUI" "NZ2" "US1" "US2" "POR" "FRA" "AUS" "NZ1" "SWE"
我还创建了一个名为:
getTimes()
例如,如果我输入:
> getTimes("GER")
[1] "11:10:02" "11:35:05" #Shows the starting and finishing times
我需要在这里做的是创建一个矩阵,显示所有国家的开始和结束时间。
例如,我应该得到以下结果的矩阵:
> raceTimes
start finish
GER "11:10:02" "11:35:05"
SUI "11:10:02" "11:35:22"
#and so on....
我的尝试:
> GER <- getTimes("GER")
> SUI <- getTimes("SUI")
> NZ2 <- getTimes("NZ2")
> US1 <- getTimes("US1")
> US2 <- getTimes("US2")
> POR <- getTimes("POR")
> FRA <- getTimes("FRA")
> AUS <- getTimes("AUS")
> NZ1 <- getTimes("NZ1")
> SWE <- getTimes("SWE")
> allTimes<-c(GER, SUI, NZ2, US1, US2, POR, FRA, AUS, NZ1, SWE)
> raceTimes <- matrix(allTimes, ncol=2)
> rownames(raceTimes) <- paste(raceIDs)
> colnames(raceTimes) <- c("start", "finish")
> raceTimes
start finish
GER "11:10:02" "11:10:02"
SUI "11:35:05" "11:34:31"
NZ2 "11:10:02" "11:10:02"
US1 "11:35:22" "11:34:45"
US2 "11:10:02" "11:10:03"
POR "11:34:12" "11:36:48"
FRA "11:10:01" "11:10:01"
AUS "11:33:29" "11:35:16"
NZ1 "11:10:01" "11:10:03"
SWE "11:36:05" "11:35:08"
正如您在上面看到的,我的矩阵不正确。例如,“GER”(“11:35:05”)的完成结果显示为“SUI”的开始时间。
请问有什么建议吗?