2011-08-29 8 views
5

का उपयोग करते हुए गूंज चौड़ाई को कैसे नियंत्रित करें मुझे पसीने के भीतर गूंज से आउटपुट की चौड़ाई के साथ समस्या है, मेरे पास बड़ी मात्रा में टेक्स्ट है। समस्या पीडीएफ के भीतर पृष्ठ से आर रन से गूंज प्रतिक्रिया है। मैंनेस्वीवे

<<>>= 
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

यह मैक पर मेरे लिए पूरी तरह से काम करता है। क्या आप टेक्सास 2.43 का उपयोग कर मैक पर अपने लेटेक्स इंस्टॉलेशन और प्लेटफ़ॉर्म – Ramnath

+1

पर अधिक जानकारी प्रदान कर सकते हैं। टीएक्स संस्करण 3.1415 9 26 (टीएक्स लाइव 2010)। आर 2.13.0। यह मेरी मशीन पर चलता है लेकिन पाठ पीडीएफ में पेज से बाहर चला जाता है। –

+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 पोस्टिंग से मार्क Schwartz द्वारा rhelp के लिए इस दृष्टिकोण का लाभ यह है कि परिणाम लग रहा है जैसे कि यह आर द्वारा मुद्रित किया गया था यहाँ समाधान है:

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

वाह। क्या वह भविष्य में 2 घंटे पहले या 89 साल था? ;-) – Andrie

+1

आप नहीं जानते थे कि मार्क एक समय भगवान था? –

संबंधित मुद्दे