I've got a problem similar to this one, but in my case the file has also white space as missing value.
I'm working with the meteorological sounding data set from the University of Wyoming, you can find an example here
What I've tried to do so far:
data = read.table("http://weather.uwyo.edu/cgi-bin/sounding?region=samer&TYPE=TEXT:LIST&YEAR=2016&MONTH=02&FROM=1212&TO=1212&STNM=83746",skip=10,nrows=100,fill=T,sep="")
It works fine, apart from the last line that has missing values where R can't place the information in the correct column.Then, I must tell R what to do when it finds multiple white space with white space as missing value together. It looks very tricky for me.
I checked the function read.fwf(), but I'm not sure how it can help me to sort my problem out.
Thank you
Luan
答案 0 :(得分:2)
The width argument can be used to specify the column width in read.fwf
read.fwf("http://weather.uwyo.edu/cgi-bin/sounding?region=samer&TYPE=TEXT:LIST&YEAR=2016&MONTH=02&FROM=1212&TO=1212&STNM=83746",
width=rep(7, 11), skip=10,n=84)
and n
sets the maximum number of rows to read in