[R] ascii or regex code for alt-enter for Excel

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 21 07:37:31 CEST 2010


On Wed, Oct 20, 2010 at 7:11 PM, Mark Kimpel <mwkimpel at gmail.com> wrote:
> I do wonder what ASCII character is represented in Windows with alt-Enter.

Using Excel 2007 on Windows, Alt-Enter is char(10).  In an empty sheet
enter these three characters into A1:

   a alt-enter b

and then in 3 other cells try this:

=find("a", A1)
=find(char(10), A1)
=find("b",A1)

and you should get 1, 2 and 3 showing that the first, second and third
characters are "a", char(10) and "b".  Also try =find(char(13),A1) to
double check that there are no char(13) characters in A1.





>
> Thanks Bill!
>
> 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
>
>
> On Wed, Oct 20, 2010 at 2:13 PM, William Dunlap <wdunlap at tibco.com> wrote:
>
>>
>> > From: r-help-bounces at r-project.org
>> > [mailto:r-help-bounces at r-project.org] On Behalf Of William Dunlap
>> > Sent: Wednesday, October 20, 2010 10:47 AM
>> > To: Duncan Murdoch; Mark Kimpel
>> > Cc: r-help at r-project.org
>> > Subject: Re: [R] ascii or regex code for alt-enter for Excel
>> >
>> > I think Excel wants a "\n" for newlines
>> > in a text cell entry but "\r\n" to separate
>> > rows of a csv file.  You may have to open
>> > the file in binary mode and put in the \r\n
>> > at line ends by hand to achieve this from R,
>> > as it tranlates all "\n"s to "\r\n"s when
>> > writing them to a file.
>> >
>> > ("\n" is not the same as "/n" in R.)
>>
>> I omitted an example:
>>  d <- data.frame(nLines=c(3,2,1),
>>     entry=c("three\nline\nentry",
>>             "two line\nentry",
>>             "one line entry"))
>>  theFile <- file("c:/temp/d.csv", open="wb") # write in binary mode
>>  write.csv(d, theFile, eol="\r\n")
>>  close(theFile)
>>
>> Now c:/temp/d.csv in Excel and you should see the
>> multiline text entries.  (Expand the cells and/or
>> formula entry area to see all the lines in an entry.)
>>
>> > Bill Dunlap
>> > Spotfire, TIBCO Software
>> > wdunlap tibco.com
>> >
>> > > -----Original Message-----
>> > > From: r-help-bounces at r-project.org
>> > > [mailto:r-help-bounces at r-project.org] On Behalf Of Duncan Murdoch
>> > > Sent: Wednesday, October 20, 2010 10:29 AM
>> > > To: Mark Kimpel
>> > > Cc: r-help at r-project.org
>> > > Subject: Re: [R] ascii or regex code for alt-enter for Excel
>> > >
>> > > 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.
>> > >
>> > > ______________________________________________
>> > > 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.
>> > >
>> >
>> > ______________________________________________
>> > 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.
>> >
>>
>
>        [[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.
>



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list