0

can anyone please find the error in the r code (automap package) below, or give me some advice about auto cross-validation??

library(automap)
mydata<-read.table(".../mydata.txt", header=T, sep=",")
x<-mydata[,1]
y<-mydata[,2]
data1<-mydata[,3]
mydata.grid<-read.table(".../mydata.grid.txt", header=T, sep=",")
coordinates(mydata)=~x+y
gridded(mydata.grid)=~x+y
mykr.cv<-autoKrige.cv(log(data1)~1, mydata, model=c("Ste"), nfold=10)

But it shows this error:

0% Error: dimensions do not match: locations 120 and data 64

The spatial data I use hase 3 columns (x, y, mydata) for 64 points, and grids data in 2 columns (x, y) which contains 97868 points.

1 Answers1

1

After loading mydata.txt, try to rename the columns of your dataframe without instantiate new vectors:

colnames(mydata) = c("x","y","data1")

then:

coordinates(mydata)=~x+y
mykr.cv<-autoKrige.cv(log(data1)~1, mydata, model=c("Ste"), nfold=10)

I've tried to answer without a reproducible example of your dataset. Next time, please provide one.

Fabio
  • 518
  • 1
  • 4
  • 10
  • Thank you so much, @Fabio; it worked properly. The data and code I wrote: https://onedrive.live.com/redir?resid=66BD1F9292741792!111&authkey=!AAdRpPlhf6Abf_s&ithint=file%2crar ...I have not added the part you mentioned though. I have another question: http://stackoverflow.com/questions/25324648/how-to-insert-x-and-y-label-and-tick-marks-in-autokrige . Please take a look at it. I would be grateful if you could help. Thank you so much for your time. (The addresses of reading files should be updated which are not specified in the code right now.) – user3918211 Aug 17 '14 at 05:08