0
나는 주어진 디렉토리의 모든 파일에서 htmlTables
을 만들고 R 인하에이를 표시 할.R Markdown 및 htmlTable. R Markdown의 루프에서 html 테이블을 생성하는 방법은 무엇입니까?
그러나 난 더 출력이없는 for
루프 htmlTable
사용하려고하면. 코드의
``{r }
path<-"~/wyniki stocks"
listFiles<-as.list(list.files(path))
for(file in listFiles){
################################
#Generating path to the current file
path1<-paste(path,"/",file, sep="")
print(path1)
#############################
#Reading File
output<-read.dta(path1)
######################################
#html table
htmlTable(output[1:2,1:2])
}
print("Why are there no tables above?")
htmlTable(output[1:2,1:2])
```
출력 : 다음은 코드가
나는 목록에 htmlTable
의 출력을 쓰고있다 마련 할 수 있었다 가장 좋은 해결책 htmlList
및 asis_output()
을 사용하여 하나씩 테이블을 표시하십시오. 그러나 이것은 또한 반복적으로 작동하지 않습니다.
# Does not work, htmlList is a list
htmlList[i]<-htmlTable(output[1:2,1:2])
for(i in 1:10)
asis_output(htmlList[i],meta='html')
#works
asis_output(htmlList[1],meta='html')
asis_output(htmlList[2],meta='html')
asis_output(htmlList[3],meta='html')
하나 또는 두 개의 테이블이 있으면 작동 할 수 있습니다. 하지만 파일 번호와 독립적으로 작동해야합니다.
# Preparing data
{r}
library(htmlTable)
library(knitr)
output <- matrix(1:4,
ncol=2,
dimnames = list(list("Row 1", "Row 2"),
list("Column 1", "Column 2")))
# Part 1
{r}
htmlTable(output)
# Part 2
{r}
for(i in 1)
htmlTable(output)
감사합니다. 이 방법으로 작동합니다. – patyk11
당신은'결과 = 'asis''를 생략하고 사용할 수'대신 knit_print'. –