Dimitri Shvorob
2010-Apr-28 14:27 UTC
[R] How to read contents of a text file into a single string?
... Both readLines() and scan() produce a number_of_lines x 1 vector; trying paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector elements (lines) into a single string? Thank you. -- View this message in context: http://r.789695.n4.nabble.com/How-to-read-contents-of-a-text-file-into-a-single-string-tp2069303p2069303.html Sent from the R help mailing list archive at Nabble.com.
Paul Hiemstra
2010-Apr-28 15:05 UTC
[R] How to read contents of a text file into a single string?
Dimitri Shvorob wrote:> ... Both readLines() and scan() produce a number_of_lines x 1 vector; trying > paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector > elements (lines) into a single string? > Thank you. >try collapse = '' cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
Erik Iverson
2010-Apr-28 15:08 UTC
[R] How to read contents of a text file into a single string?
Dimitri Shvorob wrote:> ... Both readLines() and scan() produce a number_of_lines x 1 vector; trying > paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector > elements (lines) into a single string? > Thank you.Read ?paste, specifically: If a value is specified for ?collapse?, the values in the result are then concatenated into a single string, with the elements being separated by the value of ?collapse?. You need to specify, say, collapse = " ".