Dear list, I tried to fit the model variogram to the experimental semivariogram. I used the following code: A<-read.table(file.choose(new=FALSE), sep = ",",skip=1,header=FALSE) names(A) <- c("S.N","x", "y", "B1","B2","B3","B4") library(sp) library(gstat) coordinates(A) = ~x+y C<-variogram(B1~x+y+x*y+x*x+y*y,A,cutoff=700,width=12,alpha=0,tol.hor=90) model.1 <- fit.variogram(C,vgm(4,"Sph",800,add.to=vgm(1,"Sph",40,nugget=.9))) plot(C,model=model.1,pch=1,col=blue,lty=1,lwd=2,plot.numbers=F,xlab=list("Distance(h) [m]",font=1,col="black"),ylab= list(expression("Semivariogram [-]"^2), font=1,col="black"))#,ylim = c(0,6, by=1), xlim = c(0,700, by=100)) Using the above code everything went ok. But I need to save the experimental semivariogram i.e (C) and then later utilize it to fit the model semivariogram for the same. So I first save it using the following code: write.table(C, file = "expm_vario.csv", sep = ",", col.names = T,qmethod="double") Then I used the following code to read the saved file expm_vario.csv and try to fit the model for it; B<-read.table(file.choose(new=FALSE), sep = ",",skip=0,header=T) class(B)=c("gstatVariogram","data.frame","numeric") model.2<- fit.variogram(B,vgm(4,"Sph",500,add.to=vgm(1,"Sph",80,nugget=.9))) But I couldn't fit the model. Following was the error message I got: "Error in fit.variogram(B, vgm(4, "Sph", 500, add.to = vgm(1, "Sph", 80, : REAL() can only be applied to a 'numeric', not a 'integer' "The problem seems to be the numeric and integer values but I couldn't figured it out. Any help will be greatly appreciated! Regards, Pujan _________________________________________________________________ Give to a good cause with every e-mail. Join the im Initiative from Microsoft.
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo