I need to write a table that can be opened in Excel or OpenOffice such that there are newlines embedded within cells. After much Googling and futzing, I can't figure out how to do this. The way to do this within Excel is alt-Enter and I've tried '/n', '/n/r', '/r/n' per some web suggestions without luck. Anybody know what character or ASCII code to use for this? Thanks, Mark Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 399-1219 Skype No Voicemail please [[alternative HTML version deleted]]
On 20/10/2010 1:04 PM, Mark Kimpel wrote:> I need to write a table that can be opened in Excel or OpenOffice such that > there are newlines embedded within cells. > > After much Googling and futzing, I can't figure out how to do this. The way > to do this within Excel is alt-Enter and I've tried '/n', '/n/r', '/r/n' per > some web suggestions without luck.You may need to ask an Excel expert or MS tech support. What character is Excel looking for? (Or it is possible that you have what you need, but used forward slashes when you should have used backslashes. The newline character is \n, not /n, in R.) Duncan Murdoch> Anybody know what character or ASCII code to use for this? > > Thanks, > > Mark > > Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry > Indiana University School of Medicine > > 15032 Hunter Court, Westfield, IN 46074 > > (317) 490-5129 Work,& Mobile& VoiceMail > (317) 399-1219 Skype No Voicemail please > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
On Wed, Oct 20, 2010 at 1:04 PM, Mark Kimpel <mwkimpel at gmail.com> wrote:> I need to write a table that can be opened in Excel or OpenOffice such that > there are newlines embedded within cells. > > After much Googling and futzing, I can't figure out how to do this. The way > to do this within Excel is alt-Enter and I've tried '/n', '/n/r', '/r/n' per > some web suggestions without luck. > > Anybody know what character or ASCII code to use for this? >You don't need to do anything special provided you enclose the multi-line fields in double quotes. For example, this works for me using Excel 2007: cat('HdgA,HdgB\n"A\nB",C\n', file = "my-excel-test.csv") shell("my-excel-test.csv") Note that you may need to stretch the cells in Excel to actually see the multiple lines in the multi-line cells but they are there in any case. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com