我使用R2HTML库来创建流程迭代的报告。 我有一个存储在列表中的交互数据,以及用于data.frame上每次迭代的参数。 我使用以下功能,但我无法打印迭代。 我只打印" HTML.title"一次,我在每个标题之间添加了一个NULL。你知道你是否可以在代码R2HTML中使用for循环或同时使用?知道我做错了吗?
HTML_OUTPUT_ITERATIONS<-function(epc_list, df_power_values){
require(R2HTML)
DIRECTOR<-getwd()
FOLDER<-"/outputs/"
OUTPUTS<-paste(DIRECTOR,FOLDER,sep="")
PATH_OUTPUTS<-gsub(" ","", OUTPUTS, fixed=TRUE)
i<-1
HTMLStart(outdir=PATH_OUTPUTS, file="iterations",extension="html", echo=FALSE, HTMLframe=TRUE)
HTML.title("Iterations Log Report", HR=1)
HTML.title("Report of the data obtained from the readings that have been made during the test", HR=3)
while(i<=length(df_power_values)){
HTML.title("Power:")
print(df_power_values[i,1])
HTML.title("EPC read:")
print(epc_list[i]
i<-i+1
}
HTMLStop()
}
Data.frame(df_power_values)值:
V1
1 31.5
2 31.0
3 30.5
4 30.0
5 29.5
6 29.0
7 28.5
8 28.0
9 27.5
10 27.0
11 26.5
12 26.0
13 25.5
14 25.0
15 24.5
16 24.0
17 23.5
18 23.0
19 22.5
20 22.0
列出epc_list:
[[1]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A016
5 00000000000000000000A340
6 00000000000000000000A012
7 00000000000000000000A051
8 00000000000000000000A274
[[2]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[3]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[4]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[5]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A012
6 00000000000000000000A051
7 00000000000000000000A274
[[6]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A012
6 00000000000000000000A051
7 00000000000000000000A274
[[7]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[8]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[9]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[10]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[11]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[12]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[13]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[14]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[15]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[16]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[17]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A340
5 00000000000000000000A051
6 00000000000000000000A274
[[18]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A051
5 00000000000000000000A274
[[19]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A051
5 00000000000000000000A274
[[20]]
epc
1 00000000000000000000A111
2 00000000000000000000B109
3 00000000000000000000A279
4 00000000000000000000A051
5 00000000000000000000A274
答案 0 :(得分:1)
数据帧的长度为1,因此循环在一次迭代后结束。而不是while(i<=length(df_power_values))
,请尝试while (i <= nrow(df_power_values))
或while (i <= length(df_power_values$V1))
。
答案 1 :(得分:0)
是的!是对的,然后我看到了:)非常感谢,在这里我留下了代码
while(i<=nrow(df_power_values)){
HTML.title("Power:")
HTML(df_power_values[i,1], digits=4)
HTML.title("EPC read:")
HTML(epc_list[i])
i<-i+1
}
HTMLhr()
HTMLStop()