On 30-Jul-10 12:20:35, rajibshibly wrote: > Hello, > I am brand new to R. I need to know how to output the contents > of cat function into a text file. The cat is used to output > several lines of string in the following format: > X XXX > X XX.XX > XXXX-XXXX ( XX.XX XXX ) > > I need to get the output of all these lines into a text file. > I tried to put a file name in the cat function. However the output > file only displays single line output. > Thanks
cat() is somewhat special in that, by default, it does not output a new line after each element in the list being output: cat("A B C","D E F","G H I") # A B C D E F G H I However, you can get it to inset one by using the "sep" argument (default sep = " " as in the above output): cat("A B C","D E F","G H I",sep="\n") # A B C # D E F # G H I See the description in '?cat'. The name "cat", as in UNIX 'cat', is an abbreviation for "catenate", which means to string things together in a chain. Hence the default behaviour above (but with spaces inserted to separate the original elements). For a true catenation, with nothing separating the chained elements, see: cat("A B C","D E F","G H I",sep="") # A B CD E FG H I Hoping this helps. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 30-Jul-10 Time: 17:44:26 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.