Error in reading file
1
0
Entering edit mode
azhar • 0
@azhar-11661
Last seen 7.6 years ago

I used this code to read txt file I want to use It to make volcano graph

genelist<-read.table("fexam1.txt", header=TRUE)

but it gives me error like

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 69 did not have 3 elements

for almost every file

can you tell me whats wrong

 

process • 979 views
ADD COMMENT
0
Entering edit mode
Mike Smith ★ 6.5k
@mike-smith
Last seen 5 hours ago
EMBL Heidelberg

The error message gives you a pretty good hint here - line 69 of your file does not contain 3 elements.  It has determined that there should be 3 columns of data from the first line in the file, since you specified header = TRUE

I would suggest looking at that line to understand why this is happening.  By default read.table() defines a new column every time it encounters white space.  Perhaps you have a space in that line that isn't present on the other lines?  You can use the argument sep to break on other characters.  This example would split data when it finds a tab.

genelist <- read.table("fexam1.txt", header = TRUE, sep = "\t")

For more details you can read the help file for the function with 

?read.table
ADD COMMENT

Login before adding your answer.

Traffic: 385 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6