2011-08-29 3 views
5

스웨 웨이 내 에코의 출력 너비에 문제가 있습니다. 많은 양의 목록이 있습니다. 문제는 R의 에코 응답이 pdf 내의 페이지에서 실행된다는 것입니다. 사용해 보았습니다.Sweave를 사용하여 에코 폭을 제어하는 ​​방법

<<>>= 
options(width=40) 
@ 

하지만 변경된 사항은 없습니다.

예 : 목록을 설정합니다 (라텍스에는 표시되지 않음).

<<echo=FALSE>>= 
my_list <- list(example="Site location was fixed using a Silvia Navigator handheld GPS  in October 2003. Point of reference used was the station Bench Mark. If the bench mark location was remote from the site then the point of reference used was changed to the 0-1 metre gauge. Bench Mark location was then recorded as a separate entry in the Site History section [but not used as the site location].\r\nFor a Station location map and all digital photograph's of the station, river reach, and site details see H:\\hyd\\dat\\doc. For non digital photo's taken prior to October 2003 please see the relevant station file at Tumut office.") 
@ 

목록의 항목을 표시하십시오.

<<>>= 
my_list 
@ 

나는이 cat 문으로 목록을 파괴하지 않고 작업을 얻을 수있는 방법이 있습니까.

+1

완벽하게 작동합니다. 라텍스 설치 및 플랫폼에 대한 자세한 내용을 제공 할 수 있습니까? – Ramnath

+1

texshop 2.43을 사용하는 Mac. TeX 버전 3.1415926 (TeX Live 2010). R 2.13.0. 내 컴퓨터에서 실행되지만 텍스트는 pdf의 페이지에서 실행됩니다. –

+0

"당신의 기계"는 무엇을 의미합니까? –

답변

3

capture.output()을 사용하여 목록의 인쇄 된 표현을 캡처 한 다음 writeLines()strwrap()을 사용하여 멋지게 포장 한 출력을 표시 할 수 있습니다. capture.output()은 객체의 인쇄 된 표현을 포함하는 문자열의 벡터를 반환하므로 각각을 화면/페이지에 표시 할 수 있지만 strwrap()을 사용하여 감싸줍니다.

writeLines(strwrap(capture.output(my_list))) 

생산 :

$example 
[1] "Site location was fixed using a Silvia Navigator 
handheld GPS in October 2003. Point of reference used 
was the station Bench Mark. If the bench mark location 
was remote from the site then the point of reference used 
was changed to the 0-1 metre gauge. Bench Mark location 
was then recorded as a separate entry in the Site History 
section [but not used as the site location].\r\nFor a 
Station location map and all digital photograph's of the 
station, river reach, and site details see 
H:\\hyd\\dat\\doc. For non digital photo's taken prior 
to October 2003 please see the relevant station file at 
Tumut office." 
+0

감사합니다 개빈, 치료를 작동합니다. –

1

을 2010 년 포스팅에서 마크 슈워츠에서는 rhelp이 방법의 장점은 결과 보이는이 R. 인쇄 된 것처럼 여기에 해결책이다 :

cat(paste(strwrap(x, width = 70), collapse = "\\\\\n"), "\n") 
+0

와우. 2 시간 전인가 89 년 전인가? ;-) – Andrie

+1

마크가 타임로드 였는지 몰랐습니까? –

관련 문제