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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:24:52+00:00 2026-06-09T23:24:52+00:00

I am trying to read many files into R to evaluate the data in

  • 0

I am trying to read many files into R to evaluate the data in column 14 of each into its own histogram. It seems to work up until I try to access the actual data (aside from the column names.)

The code seems to work to an extent:

    test<-sapply(1:Num.Files,function(x){readLines(File.names[x])})
    head(test)
    data<-read.table(header=TRUE,text=test[1])
    head(data)
    names(data)[14]<-'column14'
    names(data)
    data$column14

but here is the result:

test<-sapply(1:Num.Files,function(x){readLines(File.names[x])}) #Enters the data
head(test) #Can see here that the information is all there
[,1]
[1,] “Targ cov av_cov 87A_cvg 87Ag 87Agr 87Agr 87A_gra 87A%_1 87A%_3 87A%_5 87A%_10 87A%_20 87A%_30 87A%_40\t87A%_50\t87A%_75\t87A%_100”
[2,] “1:028 400\t0.42\t400\t0.42\t1\t1\t2\t41.8\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0”
[3,] “1:296 400\t0.42\t400\t0.42\t1\t1\t2\t41.8\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0”
[4,] “1:453 1646\t8.11\t1646\t8.11\t7\t8\t13\t100.0\t100.0\t87.2\t32.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0”
[5,] “1:427 1646\t8.11\t1646\t8.11\t7\t8\t13\t100.0\t100.0\t87.2\t32.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0”
[6,] “1:736 5105\t29.68\t5105\t29.68\t14\t29\t48\t100.0\t100.0\t100.0\t86.0\t65.7\t49.4\t35.5\t16.9\t0.0\t0.0”
data<-read.table(header=TRUE,text=test[1])
head(data) #all the correct column names
[1] Targ cov av_cov X87A_cvg X87Ag X87Agr X87Agr.1
[8] X87A_gra X87A._1 X87A._3 X87A._5 X87A._10 X87A._20 X87A._30
[15] X87A._40 X87A._50 X87A._75 X87A._100
<0 rows> (or 0-length row.names)
names(data)[14]<-‘column14’
names(data) #column 14 is changed as hoped
[1] “Targ” “cov” “av_cov” “X87A_cvg” “X87Ag” “X87Agr”
[7] “X87Agr.1” “X87A_gra” “X87A._1” “X87A._3” “X87A._5” “X87A._10”
[13] “X87A._20” “column14” “X87A._40” “X87A._50” “X87A._75” “X87A._100”
data$column14 #but there is nothing in the column
logical(0)

Am I using read.table incorrectly? Does anyone have a suggestion?

  • 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-09T23:24:53+00:00Added an answer on June 9, 2026 at 11:24 pm

    Yes, you are using read.table incorrectly, you’re passing it only the header line (text[1]).

    I’d call read.table directly on the file names. If you insist on passing the result of readLines, you probably want to re-join everything like paste(test, collapse="\n").

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read a JSON file into a data structure so that I
I am trying understand ViewModels deeper and I have read many articles and blogs
I'm a machine learning newbie trying to understand how Adaboost works. I've read many
Im trying to read a column of String values from my DB. Im trying
I'm creating function which will read different XML files each time that will contain
I'm trying to read the contents of a file into my program but I
I am trying to read in a file that only have one column, and
I'm trying to write a stored procedure that will read an Excel file into
Trying to read an RSS and select information using Linq but can't seem to
Trying to read headers for a csv file with: reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True) headers =

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.