[R] Weird behaviour of tab characters in a string in R (vs Python)

R. Michael Weylandt michael.weylandt at gmail.com
Thu Oct 6 21:30:40 CEST 2011


Things like hard-tabs are usually going to vary by text-editor / GUI.
Python is pretty peculiar in its use of tabs, so I wouldn't expect R
to replicate. My Matlab license is buggy right now, but I think you'd
see similar behavior there, while interactive Ruby gives an
autocomplete. I think that hits the big interactive languages that I
use. I guess my point is I think Python is the odd man out as a result
of its special tab/indentation structure, though I'd welcome
correction/elaboration because its not something I've looked at
before.

Are the tabs important? Perhaps we can help with a work around

Michael

On Wed, Oct 5, 2011 at 5:47 AM, Johnny Paulo <johnny.jp.22 at gmail.com> wrote:
> Hello,
>
> I wanted to parse some information from a text, where fields are tab
> separated.
> When I copy the text into an R session (under emacs) like:
> mystring <- "field1   field2   field3"
> the tab character is replaced by a single space!
> For ex, if I type mystring, I get:
> "field1 field2 field3"
> The tabs have disappeared!!!
>
> I checked with Python that the text I copied was tab separated indeed
>
> so I did the same, in a Python session:
> mystring = "field1   field2   field3"
> and when I type mystring, I get the expected:
> "field1\tfield2\tfield3"
>
> I am quite new to R, and there is something I am missing here.
>
> Any light will be highly appreciated.
>
> Regards
>
> Johnny
>
>        [[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.
>



More information about the R-help mailing list