I need to read a table that is a .tsv
file in R.
test <- read.table(file='drug_info.tsv') # Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # line 1 did not have 10 elements test <- read.table(file='drug_info.tsv', ) # Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # line 1 did not have 10 elements scan("drug_info.tsv") # Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # scan() expected 'a real', got 'ChallengeName' scan(file = "drug_info.tsv") # Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : # scan() expected 'a real', got 'ChallengeName'
How should I read it?
You can open TSV files with a large number of applications, including Microsoft Excel (multiplatform) and OpenOffice Calc (multiplatform). You can upload TSV files to Google Sheets to view, edit, save, and convert the files.
The very simple way to read data from TSV File in Python is using split(). We can read a given TSV file and store its data into a list.
This should do it:
read.table(file = 'drug_info.tsv', sep = '\t', header = TRUE)
Using fread from the package data.table will read the data and will skip the error you are getting using read.table.
require(data.table) data<-as.data.frame(fread("drug_info.tsv"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With