Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6360635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:40:24+00:00 2026-05-24T23:40:24+00:00

OK, I admit that the title is a bit misleading. I’m braindead currently, so

  • 0

OK, I admit that the title is a bit misleading. I’m braindead currently, so I may be missing something obvious here.

I’m working on R-powered webapp, and I’d like to pass certain parameters to read.table function – sep among others. Everything works like a charm if I’m passing single-byte characters as sep argument: ,, ;, |… but if I try to pass \t, I get an error:

invalid 'sep' value: must be one byte

of course, this happens because \t is actually escaped (\\t). Is there any chance that I can escape escapes, and pass it “as is” – i.e. a single byte string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:40:25+00:00Added an answer on May 24, 2026 at 11:40 pm

    You need to write sep="\t" as the parameter to read.table.

    In the case of a tab, it is the t that gets escaped. In other words, you are telling R that t doesn’t really mean t, but tab. If you escape the \, by using \\ then you are telling R that the \ doesn’t really mean escape but a literal \.

    Here is some code illustrating the correct usage of sep="\t" in read.table. And just for the fun of it, I use textConnection to use a connection to write to and read from, rather than using a file on disk:

    # Create a tab delimited file
    zz <- textConnection("foo", "w")
    write.table(matrix(1:12, ncol=3), file=zz, sep="\t")
    close(zz)
    foo
    
    # The simple way:
    tabsep <- "\t"
    
    # The hard way, or if data was passed from a web app and you need to clean it
    tabsep <- gsub("\\\\t", "\t", "\\t")
    
    
    # Read a tab delimited file
    zz <- textConnection(foo)
    read.table(zz, sep=tabsep)
    close(zz)
    

    This produces the following output:

      V1 V2 V3
    1  1  5  9
    2  2  6 10
    3  3  7 11
    4  4  8 12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK so I admit right off the top that this is a bit screwy
I admit that I have almost none experience of unittesting. I did a try
I must admit that I am incredibly jealous of those developers who happen to
I will openly admit that I fall on the side of Test Driven Development.
I have to admit that I'm new to Java and Android. db4o seems to
I must admit that I don't really know if this is the right place
I've a c++ project. I admit that I'm a complete ZERO in c++. But
Accepting the possibility of extreme ridicule, I must admit that I really miss sun
I have just installed Microsoft Robotics Studio 2008 R2, and I must admit that
I gotta admit that's a first-timer bug for me. I've never seen that... I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.