Hello, i'm trying to do a batch run of variogram calculations using the gstat package and the variogram function. The main issue is that "variogram" outputs a data frame, and i'm having trouble figuring out how to store each iteration of all the data frame components in a new data frame, organized by the subsetting ID. My code is below, note i had to replace any data references with dummy names. I give an example of the dummy data. Any help or hints with this would be greatly appreciated. Thankyou.
Dummydata.csv:
|Location_ID |Sample_ID|x|y|Value|
|Dummy1|Dummy1-1|0|462.725|3.4204|
|Dummy1|Dummy1-2|0|461.725|3.474|
|Dummy1|Dummy1-3|0|460.475|3.3534|
|Dummy1|Dummy1-4|0|458.475|3.4539|
|Dummy1|Dummy1-5|0|456.475|3.3601|
|Dummy1|Dummy1-6|0|454.475|3.14235|
|Dummy1|Dummy1-7|0|452.475|2.80534|
|Dummy1|Dummy1-8|0|450.475|2.93197|
|Dummy1|Dummy1-9|0|462.651|3.13632|
|Dummy1|Dummy1-10|0|461.151|3.5477|
|Dummy1|Dummy1-11|0|459.901|3.7085|
|Dummy1|Dummy1-12|0|457.901|3.28506|
|Dummy2|Dummy2-1|0|452.77|3.47534|
|Dummy2|Dummy2-2|0|447.77|3.39896|
|Dummy2|Dummy2-3|0|442.77|3.24419|
|Dummy2|Dummy2-4|0|437.77|3.5276|
|Dummy2|Dummy2-5|0|437.77|3.6951|
|Dummy3|Dummy3-1|0|456.274|3.5678|
|Dummy3|Dummy3-2|0|455.274|3.6214|
|Dummy3|Dummy3-3|0|454.524|3.47132|
|Dummy3|Dummy3-4|0|453.024|2.7906|
|Dummy3|Dummy3-5|0|451.024|3.4338|
|Dummy3|Dummy3-6|0|448.024|2.48441|
|Dummy3|Dummy3-7|0|445.024|2.76849|
|Dummy3|Dummy3-8|0|443.024|2.55744|
|Dummy3|Dummy3-9|0|440.024|2.53399|
|Dummy3|Dummy3-10|0|436.024|2.7169|
library(gstat)
library(sp)
my_data <- read.csv("Dummydata.csv")
boring_list <- c(unique(my_data[ , c("Location_ID")]))
length(boring_list)
coordinates(my_data)=~x+y
Computation of the variogram
data.frame(matrix(NA, nrow = 1680, ncol = 6))
for(i in 3){
Boring <- subset(my_data, Location_ID==boring_list[i])
data.frame[i]=variogram(value~1, data=Boring,cutoff=7, width=0.7)
}