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 8315451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:08:01+00:00 2026-06-08T21:08:01+00:00

I have a tab-delimited DAT file that I want to read into R. When

  • 0

I have a tab-delimited DAT file that I want to read into R. When I import the data using read.delim, my data frame has the correct number of columns, but has more rows than expected.

My datafile represents responses to a survey. After digging a little deeper, it appears that R is creating a new record when there is a “.” in a column that represents an open-ended response. It appears that there are times when a respondent may have hit “enter” to add a new line.

Is there a way to get around this? I read the help, but I am not sure how I can tell R to ignore this character in the character response.

Here is an example response that parses incorrectly. This is one response, but you can see that there are returns that put this onto multiple lines when parsed by R.

possible ask for size before giving free tshirt.
 Also maybe have the interview in conference rooms instead of tight offices. I felt very cramped.
 I would of loved to have gone, but just had to make a choices and had more options then I expected.

I am analyzing the data with SPSS and the data were brought in fine, however, I need to use R for more advanced modeling

Any help will be greatly appreciated. Thanks in advance.

  • 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-06-08T21:08:02+00:00Added an answer on June 8, 2026 at 9:08 pm

    There is an ‘na.strings’ argument. You don’t offer any test case, but perhaps you can to this:

    read.delim(file="myfil.DAT", na.strings=".")
    

    I think it would be good if you could produce an edit to your question that better demonstrated the problem. I cannot create an error with a simple effort:

    > read.delim(text="a\tb\t.\nc\td\te\n",header=FALSE)
      V1 V2 V3
    1  a  b  .
    2  c  d  e
    > read.delim(text="a\tb\t.\nc\td\te\n",header=FALSE, na.strings=".")
      V1 V2   V3
    1  a  b <NA>
    2  c  d    e
    

    (After the clarification that above comments are not particularly relevant.) This will bring in a field that has a linefeed in it …. but it requires that the “field” be quoted in the original file:

    > scan(file=textConnection("'a\nb'\nx\t.\nc\td\te\n"), what=list("","","") )
    Read 2 records
    [[1]]
    [1] "a\nb" "c"   
    
    [[2]]
    [1] "x" "d"
    
    [[3]]
    [1] "." "e"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab-delimited file that has over 200 million lines. What's the fastest
I need to read test.TXT file(tab delimited) into MATLAB. TXT file have form: Datum
I have a data set that has two tab delimited columns that I plot
Let's say I have a tab-delimited text file that contains data arranged in columns
I have a 600MB tab delimited file that needs to be sorted using only
I have a lot of tab delimited data that is organized into multiple rows
I have tab delimited data that I am exporting a select few columns into
I have a tab delimited text file with the following data: ahi1 b/se ahi
I have a tab delimited file on a shared path. I've setup that flat
I have a text file with tab delimited data spread across 16 columns. 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.