我正在使用knitr来生成一个动态的HTML网站。我想把数据文件中的文本作为普通文本。
#my dataframe
text
my first paragraph
my second paragraph
在针织品中,我可以使用cat()或print(),但是它们在R输出样式中生成难看的块。
{r
cat(text)
print(text)
}
是否有可能输出文本/字符串的“正常段落”风格,就像在写标记?
还是更快或者更容易创建一个新的主题?
更新:我正在遍历dataframe df:
variable1, variable2, text
2, 10, hello
5, 11,
我有一个调用函数的r标记。该函数呈现另一个r标记文档,其中我在循环中包含kable。我无法打印在循环中调用的kable。
下面是一个代码示例:
# function definition
test.kable <- function(filename){
rmarkdown::render(filename)
}
#test.rmd
```{r,echo=FALSE,results='asis'}
对于(1:2中的i){
print(kable(head(Iris)
}
kable(尾部(虹膜))
#main r markdown in which I call the
关于knitr块选项,我有两个问题:
1)是否可以从代码块中重写knitr块选项,以便在同一块中应用这些选项?例如,编写类似于以下行的内容,并获得结果as-is:
```{r, results= "markup"}
knitr::opts_chunk$set(results= "asis")
for (i in 1:5)
print("# This text should be printed 'as-is'")
附注:我对knitr::asis_output很熟悉。
2)可以从块内部获取块选项吗?例如,使用以下代码:
我使用knitr 0.5进行分析,它抛出以下警告
Warning in parse_params(params) :
(*) NOTE: I saw options " label = TrtScores-SD-Response, echo = FALSE, results = asis"
are you using the old Sweave syntax? go http://yihui.name/knitr/options
对于这个区块
<< label = TrtScores-SD-Response, echo = FALSE, results =
我希望从给定目录中的所有文件创建htmlTables,并在R标记中显示它们。
但是,当我尝试在htmlTable循环中使用for时,没有输出。以下是代码:
``{r }
path<-"~/wyniki stocks"
listFiles<-as.list(list.files(path))
for(file in listFiles){
################################
#Generating path to the current file
path1<-paste(path,"/",file,