I have about 60 .Rdata files in the same directory. The object name in all those .Rdata are same. I want to write some code to load and print all 60 .Rdata file and each file in the new page. For example, if the file name is file_1.rdata
, file_2.rdata
and file_3.rdata
. The object name in all three .Rdata files is table
. The following knitr code showed exactly what I want,
>\```{r,echo=FALSE}
>load("file_1.rdata")
>print(table)
>\```
>\pagebreak
>\```{r,echo=FALSE}
>load("file_2.rdata")
>print(table)
>\```
>\pagebreak
>\```{r,echo=FALSE}
>load("file_3.rdata")
>print(table)
>```
>\pagebreak
But I have more than 60 files, it is really hard to write all the code by hand. I can write for loop in R block, however, how can I make a new page for each .rdata file?
The for loop will be
>\```{r,echo=FALSE}
>names <- c("file_1.rdata","file_2.rdata","file_3.rdata")
>for(i in 1:length(names)){
> current_object <- names[i]
> load(current_object)
> print(table)
>}
>\```