knitr::opts_chunk$set(echo = TRUE)
experimental_flakes <- readxl::read_xlsx("experimental_flakes.xlsx")
View(experimental_flakes)
experimental_cores <- readxl::read_xlsx("experimental_cores.xlsx")
knitr::opts_chunk$set(echo = TRUE)
library(readxl)
# The code calculates summary statistics for the variable "Perc_extracted_volume" grouped by "Raw_material" using the ddply() function from the plyr package. The resulting summary includes the number of observations (N), mean, median, minimum (Min), maximum (Max), standard deviation (SD), and coefficient of variation (CV). The summary results are stored in the object "Summary_results" and displayed.
Summary_results <- ddply(coresvrm, .(Raw_material), summarise,
N = length(Perc_extracted_volume),
Mean = round(mean(Perc_extracted_volume), 2),
Median = round(median(Perc_extracted_volume), 2),
Min = round(min(Perc_extracted_volume), 2),
Max = round(max(Perc_extracted_volume), 2),
SD = round(sd(Perc_extracted_volume), 2),
CV = round(sd(Perc_extracted_volume) / mean(Perc_extracted_volume), 2))
library(dplyr)
library(ggplot2)
library(readxl)
library(gridExtra)
library(plyr)
library(viridis)
library(survminer)
library(ggpubr)
library(readr)
library(fitdistrplus)
library(fitdistrplus)
# # Flakes data
# fumane_flakes <- read_csv2("fumane_flakes.csv")
# # Cores data
# fumane_cores <- read_csv2("fumane_cores.csv")
fumane_flakes <- readxl::read_xlsx("fumane_flakes.xlsx")
fumane_cores <- readxl::read_xlsx("fumane_cores.xlsx")
# corrdimslength takes gen (generation) and median as inputs and returns the corrected length of the core by multiplying gen and median
corrdimslength<-function(gen,median){
corrected_dim_length<- (gen*median)
return(corrected_dim_length)
}
# corrdimslength2 takes gen1, gen2, and dim as inputs and returns the corrected length of the core by adding gen1, gen2, and dim.
corrdimslength2<-function(gen1,gen2, dim){
corrected_dim_length2<- (gen1+gen2)+dim
return(corrected_dim_length2)
}
# corrdims takes gen, median, and dim as inputs and returns the corrected dimensions of the core by multiplying gen and median and adding dim.
corrdims<-function(gen,median,dim){
corrected_dim<- (gen*median)+dim
return(corrected_dim)
}
# The code filters a dataset called "fumane_flakes" based on specific conditions and creates two separate subsets of data named "group1" and "group2".
fumane_flakes <- subset(fumane_flakes, !is.na(Thickness) & Group == "1")
group1 <- filter(fumane_flakes, Basic_Blank %in% c("Flake", "Tablet"))
group2 <- filter(fumane_flakes, Basic_Blank %in% c("Flake", "Blade", "Bladelet"))
#The code filters a dataset called "fumane_cores" to create a subset called "cores_final". It also transforms the "Classification_B" and "Production" columns in the "cores_final" dataframe by changing their data type and modifying their levels. Additionally, the "Volume" column values are divided by 1000.
(cores_final <- fumane_cores %>%
filter(Group == "1") %>%
mutate(Classification_B = factor(Classification_B, levels = c("Initial", "Carinated", "Narrow", "Wide", "Semicircumferential", "Multiplatform")),
Production = factor(Production, levels = c("Blade", "Blade-flake", "Blade-bladelet", "Bladelet")),
Volume = Volume / 1000))
# The code below calculates the mean and median of the "Thickness" variable grouped by "Group" and "Raw_material" in two separate datasets, "group1" and "group2" respectively. The results are then joined with the "cores_final" dataset.
summarymedianplatform <- group1 %>%
group_by(Raw_material) %>%
dplyr::summarise(meanplatform = mean(Thickness), medianplatform = median(Thickness))
summarymedianbase <- group2 %>%
group_by(Raw_material) %>%
dplyr::summarise(meanbase = mean(Thickness), medianbase = median(Thickness))
cores_final <- cores_final %>%
left_join(summarymedianplatform, by = c("Raw_material")) %>%
left_join(summarymedianbase, by = c("Raw_material"))
cores_final
cores_final <- cores_final %>%
mutate(corrected_length_platform = corrdimslength(Gen_Length_platform, medianplatform),
corrected_length_base = corrdimslength(Gen_Length_base, medianbase),
corrected_length = corrdimslength2(corrected_length_platform, corrected_length_base, L),
corrected_width = corrdims(Gen_Width, medianbase, W),
corrected_thickness = corrdims(Gen_Thickness, medianbase,T))
# The code calculates additional variables in the "cores_final" dataset, including estimated volume, percentages of remaining and extracted volume, scar density index, logarithm of scar density index, non-cortical area, and percentage of non-cortical surface
cores_final <- cores_final %>%
mutate(est_vol = (pi * ((corrected_width/2)^2) * corrected_length) / 1000,
Perc_remaining_volume = (Volume / est_vol) * 100,
Perc_extracted_volume = 100 - Perc_remaining_volume,
SDI = Scars / Surface,
logSDI = log(SDI),
no_cortical_area = Surface - Co_Area,
perc_nco = (no_cortical_area / Surface) * 100)
coresvrm <- cores_final %>%
filter(Blank %in% c("Nodule", "Slab", "Block", "Undetermined"))
Figure6a<-ggplot(coresvrm, aes(x=Raw_material, y=Perc_extracted_volume, fill=Raw_material)) +
geom_boxplot(alpha=.7) +
geom_jitter(aes(colour=factor(Raw_material)), position=position_jitter(0.2)) +
theme_classic() +
theme(legend.position="none", text=element_text(size=14)) +
labs(x="Raw material", y="Percentage of Extracted Volume (%)") +
scale_y_continuous(breaks=seq(from=0, to=100, by=10), limits=c(0, 100)) +
scale_fill_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff")) +
scale_color_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff"))
Figure6b<- ggplot(cores_final, aes(x=Raw_material, y=SDI, fill=Raw_material)) +
geom_boxplot(alpha=.7) +
geom_jitter(aes(colour=factor(Raw_material)), position=position_jitter(0.2)) +
theme_classic() +
theme(legend.position="none", text=element_text(size=14)) +
labs(x="Raw material", y="SDI") +
scale_y_continuous(breaks = seq(from= 0, to=0.015, by=0.001), limits =c(0,0.015)) +
scale_fill_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff")) +
scale_color_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff"))
Figure6c<-ggplot(cores_final, aes(x=Raw_material, y=perc_nco, fill=Raw_material)) +
geom_boxplot(alpha=.7) +
geom_jitter(aes(colour=factor(Raw_material)), position=position_jitter(0.2)) +
theme_classic() +
theme(legend.position="none", text=element_text(size=14)) +
labs(x = "Raw material",y = "Percentage of Non cortical surface(%)") +
scale_y_continuous(breaks = seq(from= 0, to=100, by=10), limits =c(0,100)) +
scale_fill_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff")) +
scale_color_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff"))
Figure6d<-ggplot(cores_final, aes(x=Raw_material, y=Volume, fill=Raw_material)) +
geom_boxplot(alpha=.7) +
geom_jitter(aes(colour=factor(Raw_material)), position=position_jitter(0.2)) +
theme_classic() +
theme(legend.position="none", text=element_text(size=14)) +
labs(x = "Raw material",y = "Volume (cm3)") +
scale_y_continuous(breaks = seq(from= 0, to=150, by=10), limits =c(0,150)) +
scale_fill_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff")) +
scale_color_manual(values=c("#295673ff", "#4f90a6ff", "#68abb8ff", "#84c3c9ff", "#a7dcd8ff"))
Figure6az <- ggarrange(Figure6a, labels = "a")
Figure6bz <- ggarrange(Figure6b, labels = "b")
Figure6cz <- ggarrange(Figure6c, labels = "c")
Figure6dz <- ggarrange(Figure6d, labels = "d")
Figure6 <- grid.arrange(arrangeGrob(Figure6az, Figure6bz, ncol = 2), arrangeGrob(Figure6cz, Figure6dz, ncol = 2), nrow = 2)
#To save the figure run the code below
#ggsave("Figure 6 Raw material", plot = Figure6, width = 40, height = 40, device = "png", units = "cm", dpi = 600)
# The code calculates summary statistics for the variable "Perc_extracted_volume" grouped by "Raw_material" using the ddply() function from the plyr package. The resulting summary includes the number of observations (N), mean, median, minimum (Min), maximum (Max), standard deviation (SD), and coefficient of variation (CV). The summary results are stored in the object "Summary_results" and displayed.
Summary_results <- ddply(coresvrm, .(Raw_material), summarise,
N = length(Perc_extracted_volume),
Mean = round(mean(Perc_extracted_volume), 2),
Median = round(median(Perc_extracted_volume), 2),
Min = round(min(Perc_extracted_volume), 2),
Max = round(max(Perc_extracted_volume), 2),
SD = round(sd(Perc_extracted_volume), 2),
CV = round(sd(Perc_extracted_volume) / mean(Perc_extracted_volume), 2))
Summary_results
#The code performs the Kruskal-Wallis tests to assess the equality of medians among different groups for the variables "Perc_extracted_volume," "SDI," and "perc_nco" based on the levels of the "Raw_material" column in the respective datasets "coresvrm" and "cores_final."
kruskal.test(Perc_extracted_volume ~ Raw_material, data = coresvrm)
kruskal.test(SDI ~ Raw_material, data = cores_final)
kruskal.test(perc_nco ~ Raw_material, data = cores_final)
dummymat <- data.frame(Raw_material = c("Maiolica", "Other", "S_Rossa", "S_Variegata", "S_Variegata 3"),
Perc_extracted_volume = rep(100, 5))
reduction_cores <- cores_final[c(4, 36)]
weibull_cores <- rbind(reduction_cores, dummymat)
View(dummymat)
View(cores_final)
View(cores_final)
View(dummymat)
