Reputation: 151
I'm using the library R2HTML to create a report of the iterations of a process. I have the data of interactions stored in a list, and the parameter used for each iteration on a data.frame. I'm using the following function, but I can not I print the iterations. I only print the "HTML.title" a single time, and I added a NULL between each title. You know if you can use the for loop or while within the code R2HTML? Any idea I do wrong?
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) 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
List 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
Upvotes: 0
Views: 149
Reputation: 151
Yes! were right, then I saw it :) thank you very much, here I leave the code
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()
Upvotes: 0
Reputation: 3615
The length of your data frame is 1, so your loop ends after one iteration. Instead of while(i<=length(df_power_values))
, try while (i <= nrow(df_power_values))
or while (i <= length(df_power_values$V1))
.
Upvotes: 1