The formula used is based from Hvorslev 1951 F factor is calculated from his figure 12, from case 8.

#open the  libraries
library(readxl)
library(readr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ purrr     1.1.0
## ✔ forcats   1.0.0     ✔ stringr   1.5.2
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(openxlsx)
## Warning: package 'openxlsx' was built under R version 4.5.3
library(ggplot2)
#open excel sheet from diver who recorded the water level decrease already calculated with pressure and tidy

Diver_data=read_excel("C:/Users/LANGLAIP/Desktop/SC35PZ - Calculated data_for slug test trial.xlsx") #change path if necessary
## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
View(Diver_data)

#remove useless columns
Diver_data_tidy = Diver_data |> 
  select(-c(6:18))
  
#Attribute columns names as the text in the first row
colnames(Diver_data_tidy) = Diver_data_tidy[1, ]

#transform the first column in real date
Diver_data_tidy[[1]] <- as.POSIXct(
  as.numeric(Diver_data[[1]]) * 86400,
  origin = "1899-12-30",
  tz = "Europe/Paris"
)
## Warning in as.POSIXct(as.numeric(Diver_data[[1]]) * 86400, origin =
## "1899-12-30", : NAs introduced by coercion
#remove first column and change in  numeric the values
Diver_data_tidy = Diver_data_tidy[-1, ] |> 
  mutate(across(-1, as.numeric))


view(Diver_data_tidy)
#determination of shape factor F based on case 8 from Hvorslev and the known diameter of our piezometer
L = 0.3 #length of perforation on the tube in m
D = 0.02 #diameter of the tube where there is the perforations in m
r = 0.01 #Radius of the well casing in m  
F = 2*pi*L/(log(L/D+ sqrt(1+(L/D)^2)))
#new column calculated from integration of outflow equation from Hvorslev 1951 and Ronkanen 2005

z = 104.2  #enter  WL in mOD from measurement before introducing the water
h0 = 105 # enter initial WL in mOD after introduction the water at T0

Diver_data_tidy_calcul_ratioWL = Diver_data_tidy |> mutate(ratio_Wl = log10((z-`WL Depth in mOD`)/(z-h0)))

view(Diver_data_tidy_calcul_ratioWL)
#plot of new column against time, to determine the slope that is equal to - FK/(pi*r^2)

ggplot(Diver_data_tidy_calcul_ratioWL, aes(x = `Date/Time`, y = `ratio_Wl`)) +
  geom_point(color =  'blue')+
  geom_smooth(method = "lm", color = "red", se = TRUE) 
## `geom_smooth()` using formula = 'y ~ x'

linear_model = lm(`ratio_Wl` ~  `Date/Time`, Diver_data_tidy_calcul_ratioWL) #model fitting
slope = coef(linear_model)["`Date/Time`"]  # only the slope, not intercept
#determination of permability K 
# slope = -FK / (pi * r^2)
# => FK = -slope * pi * r^2

K = - (slope * pi * (r)^2)/ (F)

print(K)
##  `Date/Time` 
## 1.284274e-07