Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

R read.table: how to avoid error from column mismatch

$
0
0

I'm sharing here a text file a need to read into R

https://www.filehosting.org/file/details/846022/PLT_PERIOD_ALL_175_P98.PLT

this is what I've done so far

fname<-'PLT_PERIOD_ALL_175_P98.PLT'

rt0<-read.table(fname, skip=8, header = FALSE,
           stringsAsFactors = FALSE)
##Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
##               line 84 did not have 10 elements

rt1<-read.table(fname, skip=8, header = FALSE, 
               stringsAsFactors = FALSE, fill=TRUE)
# this is messing up the last two columns by row 84

rt2<-read.table(fname, skip=8, header = FALSE, 
               flush = TRUE, stringsAsFactors = FALSE, fill=TRUE)
# this is skipping one column

rt3<-read.table(fname, skip=8, header = FALSE, sep='\t',
               flush = TRUE, stringsAsFactors = FALSE, fill=TRUE)
# this is reading all in one column


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>