Hi everyone,

I'm trying to create a variogram using packages gstat and sp.

the script goes as follow :

reszn <- read_excel("C:/....../residuszn.xlsx")

head(reszn)

coordinates(reszn)=~x+y

class(reszn)

vario_reszn<-variogram(reszn~1, data=reszn)

plot(vario_reszn)

the class(reszn) gives me this output :

[1] "SpatialPointsDataFrame"

attr(,"package")

[1] "sp"

so it does not seem to have any issue at this point

but when it comes to

vario_reszn<-variogram(reszn~1, data=reszn)

I have this error popping out

Error in model.frame.default(terms(formula), as(data, "data.frame"), na.action = na.fail) :

the object isn't a matrix

I tried to convert my spatialized dataframe as a matrix using

mreszn<-data.matrix(reszn,rownames.force = FALSE)

and I have this error :

Error in as.vector(data) :

No method to automaticaly convert this S4 class into vector.

So I don't know what to do anymore... Any help would be very welcome

thanks

PS : error messages have been translated from french

PPS: I don't have any NA in my data frame.