2

I have a table of info from the web with unusual separators. Between columns, it has '1-space and '1-tab'. When I used the std. 'read.table' with sep=" \t" R kicked it back saying it could only take one byte for a separation. Can I use 'read.table' or something else or should I just run gsub or grep, instead?

2
  • 4
    Doesn't the default, sep="", split on white space?
    – joran
    Aug 17, 2011 at 0:59
  • @joran is correct; you shouldn't need to specify sep= Aug 17, 2011 at 2:10

1 Answer 1

2

Try adding this parameter to your read.table call keeping sep='\t':

strip.white=TRUE

Setting this flag to TRUE will strip leading and trailing white space (unless quoted) that surrounds each entry in a column.

1
  • yep--since i'm nearly always working on python and R projects side-by-side, i do that all the time (as well as 'len' instead of 'length'). Edited to fix.
    – doug
    Aug 17, 2011 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.