[R] Split a string of oneline into 2 lines.

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed May 14 18:07:15 CEST 2008



A Ezhil wrote:
> Hi,
> 
> I am trying to split a string into 2 separate strings
> in 2 lines. So, tried with
> 
> sprintf("%s \n %s", "ID", "Name")
> 
> But R prints: [1] "ID \n Name" instead of 
> ID
> Name

> Is it something I am missing here? 


Yes, in order to respect teh control character you have to cat() it as in:

cat(sprintf("%s \n %s", "ID", "Name"))

Uwe Ligges


> Thanks in advance.
> 
> Best regards,
> Ezhil
> 
> ______________________________________________
> 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.



More information about the R-help mailing list