[R] can I paste 'newline'?
runner
sunnyside500 at gmail.com
Fri Jul 20 19:42:47 CEST 2007
Thanks for replied from you all. I 've got better understanding of what
cat/paste does. what I am trying is to make FASTA format data. i.e. for each
line starting with '>', add '\n' at both ends while get rid of all '\n's for
the rest.
e.g. this is original messy data, I need to remove newlines within the text
bodies:
>no1
this is the first entry ('\n')
but here is extra newline('\n')
and also here that we need to remove.
>no2
this is the second entry, which is fine in format.
>no3
....
Of course, perl would be good at this, but I want to try with R for the
other reason.
thanks.
Duncan Murdoch-2 wrote:
>
> On 19/07/2007 7:41 PM, runner wrote:
>> It is ok to bury a reg expression '\n' when using 'cat', but not 'paste'.
>> e.g.
>>
>> cat ('I need to move on to a new line', '\n', 'at here') # change line!
>> paste ('I need to move on to a new line', '\n', 'at here') # '\n' is just
>> a
>> character as it is.
>>
>> Is there a way around pasting '\n' ? Thanks a lot.
>
> What do you want to get? Do you want a two element vector? Then use
> c(). Do you want a one element vector that prints on two lines? Use
> either form, they both work (but you need to use cat() to do the display).
>
> > x <- paste ('I need to move on to a new line', '\n', 'at here')
> > cat(x)
> I need to move on to a new line
> at here>
>
>
--
View this message in context: http://www.nabble.com/can-I-paste-%27newline%27--tf4114350.html#a11712720
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list