我希望使用R来绘制不同数据库系统性能评估结果的图表。对于每个系统,我加载了相同的数据,并在多次迭代中执行相同的查询。
单个系统的数据如下:
我可以把所有内容放进一个函数中,在for循环中计算平均矩阵,但我感觉应该有一种更优雅的解决方案。你有什么想法吗?
对于只有部分结果的情况,例如某次迭代的行数小于其他情况下的行数,我该怎么办呢?
谢谢!
单个系统的数据如下:
"iteration", "lines", "loadTime", "query1", "query2", "query3"
1, 100000, 120.4, 0.5, 6.4, 1.2
1, 100000, 110.1, 0.1, 5.2, 2.1
1, 50000, 130.3, 0.2, 4.3, 2.2
2, 100000, 120.4, 0.1, 2.4, 1.2
2, 100000, 300.2, 0.2, 4.5, 1.4
2, 50000, 235.3, 0.4, 4.2, 0.5
3, 100000, 233.5, 0.7, 8.3, 6.7
3, 100000, 300.1, 0.9, 0.5, 4.4
3, 50000, 100.2, 0.4, 9.2, 1.2
我现在需要的(用于绘图)是一个包含这些测量值平均值的矩阵或数据框。
目前我正在执行以下操作:
# read the file
all_results <- read.csv(file="file.csv", head=TRUE, sep=",")
# split the results by iteration
results <- split(all_results, all_results$iteration)
# convert each result into a data frane
r1 = as.data.frame(results[1])
r2 = as.data.frame(results[2])
r3 = as.data.frame(results[3])
# calculate the average
(r1 + r2 +r3) / 3
我可以把所有内容放进一个函数中,在for循环中计算平均矩阵,但我感觉应该有一种更优雅的解决方案。你有什么想法吗?
对于只有部分结果的情况,例如某次迭代的行数小于其他情况下的行数,我该怎么办呢?
谢谢!