죄송합니다.이 바보 같은 질문이지만 knitr에서 R 함수를 반복하는 방법을 아는 사람이 있습니까? 지금까지 내 문제는 라텍스에서 R 함수로 변수를 전달하는 것입니다. 나는 이런 식으로 뭔가를 시도하고있다 :knitr with latex forloop
\documentclass{article}
\usepackage{forloop}
\newcounter{ind}
\begin{document}
%Simple R function:
<<simpleRFun, results='asis' ,echo=FALSE>>=
simpleRFun = function(ind){
set.seed(ind) ;
plot(runif(100)) ;
}
@
%Run the function for value of 1
<<>>=
simpleRFun(1)
@
%Run the function for value of 2
<<>>=
simpleRFun(2)
@
%Loop over values of 1 and 2:
\forloop{ind}{1}{\value{ind} < 3}{
\arabic{ind}
}
%Loop over values of 1 and 2 and pass to R function:
%Everything runs fine until this line:
\forloop{ind}{1}{\value{ind} < 3}{
<<>>=
simpleRFun(ind)
@
}
\end{document}
나는 다음과 같은 오류가 점점 오전 :
Runaway argument?
#### Error: object 'ind' not found \end {verbatim} \end {kframe} \end \ETC.
./knitr-minimal.tex:97: Paragraph ended before \@xverbatim was complete.
<to be read again>
\par
l.97 }
감사합니다 도움을 사전에.
왜 첫 번째 청크에'results = 'asis''을 사용합니까? 그 청크에는 텍스트 출력이 없으므로 의미가 없습니다. 게다가'echo = FALSE'로 R 소스를 감추었 기 때문에 기본적으로 tex –
에 아무 것도 쓰이지 않을 것입니다.'brew'로 할 수 있고 출력 가능한 파일을 출력 할 수 있습니다. – baptiste