diff --git a/DESCRIPTION b/DESCRIPTION index 5a2d43d..9355988 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,6 +7,7 @@ Depends: R (>= 3.1.2) License: MIT, 2015, Ben Marwick LazyData: true Imports: + gridExtra, knitr, ggplot2, reshape2, diff --git a/NAMESPACE b/NAMESPACE index 9182d02..ffd604b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(bayes_slope_test) export(bayes_slopes_chrono_data) export(bayes_test_slopes_chrono_data) export(clean_lithics_data) +export(combine_lens_plots) export(get_chrono_data) export(get_lithics_data) export(interpolate_chrono_data) diff --git a/R/functions.R b/R/functions.R index f4b9589..9fbb840 100644 --- a/R/functions.R +++ b/R/functions.R @@ -613,11 +613,12 @@ get_lithics_data <- function(){ clean_lithics_data <- function(lithics){ - # filter the data for display (remove some dates ) + # filter the data for display (remove some dates that show inversions) lithics$C14 <- as.numeric(as.character(lithics$C14)) lithics$C14[lithics$C14 %in% c(0.7, 15.0, 24)] <- NA - # filter anomalous spit + + # filter anomalous spit, which has an usual depth value lithics <- lithics[!(lithics$Spit == 62),] # get rid of NA rows for total artefact count @@ -635,7 +636,7 @@ clean_lithics_data <- function(lithics){ #' @export #' @examples #' \dontrun{ -#' lithics_data_plotted <- plots_lithics_data(lithics_data, bayes_cp_result$cal.date.lo) +#' lithics_data_plotted <- plots_lithics_data(lithics_data_cleaned, bayes_cp_result$cal.date.lo) #' } plots_lithics_data <- function(lithics, cal.date.lo){ @@ -650,8 +651,9 @@ plots_lithics_data <- function(lithics, cal.date.lo){ ylab("Number of stone artefacts >6 mm") + annotate("text", x = lithics$Spit, y = 615, label = round(lithics$C14, 0), size = 4) + annotate("text", x = lithics$Spit, y = 615, label = round(lithics$OSL, 0), colour = "red", fontface="bold.italic", size = 4) + - annotate("text", x = 60, y = 615, label = "ka",size = 4) + - ylim(0,615) + annotate("text", x = 50, y = 615, label = "ka",size = 4) + + ylim(0,615) + + xlim(0,50) p1 # save plot as SVG for finessing... ggsave(file = "figures/Fig_6_lithics_over_time_from_1989_for_paper.svg") @@ -878,8 +880,8 @@ clust <- chclust(diss, method = "coniss") # remove NA d[is.na(d)] <- 0 strat_plot[is.na(strat_plot)] <- 0 -# save plot to file -png("figures/stratplot.png",width = 1000, height = 500) +# save plot to file, this is figure 9 +png("figures/Fig_9_stratplot.png",width=10, height=5, units="in", res=1200) x <- strat.plot(strat_plot[,-ncol(strat_plot)] * 100, scale.minmax = TRUE, yvar = as.numeric(strat_plot$age), @@ -940,19 +942,20 @@ lens_differences_raw <- function(){ library("reshape2") dat_raw <- read.csv("data/Lithics_table_from_paper_on_1989_dig.csv") - dat_raw$part <- with(dat_raw, ifelse(Spit %in% c(37:40), 'above', - ifelse(Spit %in% c(41, 43, 62), 'lens', - ifelse(Spit %in% c(42, 44:49), 'below', + dat_raw$part <- with(dat_raw, + ifelse(Spit %in% c(37:40), 'above', + ifelse(Spit %in% c(41, 43, 62), 'lens', + ifelse(Spit %in% c(42, 44:49), 'below', "who_cares")))) dat_raw[10:15,] <- apply(dat_raw[10:15,], 2, as.numeric) # combine Quartzite types dat_raw$Quartzite <- dat_raw %>% - select(Local.Coarse.Grained.Quartzite, - Fine.Grained.Exotic.Quartzite, - Brown.Quartzite) %>% - rowSums(na.rm = TRUE) + dplyr::select(Local.Coarse.Grained.Quartzite, + Fine.Grained.Exotic.Quartzite, + Brown.Quartzite) %>% + rowSums(na.rm = TRUE) # put things in order for the plot @@ -977,6 +980,8 @@ p1 <- ggplot(dat_raw1, aes(variable, perc)) + ggsave("figures/raw-materials-lens.png", width = par("din")[1] * 1.6) +raw_dat_long <- dat_raw1 + p2 <- ggplot(dat_raw1, aes(part, perc, fill = variable)) + geom_bar(stat="identity", position=position_dodge()) + theme_minimal() @@ -1008,6 +1013,7 @@ raw_table <- dcast(ret, part ~ variable, value.var = 'n')[,-1] return(list(p1 = p1, p2 = p2, p3 = p3, + raw_dat_long =raw_dat_long, raw_chi_fisher = raw_chi_fisher, raw_table = raw_table)) @@ -1088,6 +1094,8 @@ p1 <- ggplot(dat_tech1, aes(variable, percentage)) + ggsave("figures/tech-lens-difference.png", width = par("din")[1] * 1.6) +tech_dat_long <- dat_tech1 + # The plot of the types in each zone by percentage of the entire count of types for spits ggplot(dat_tech_all, aes(variable, percentage)) + @@ -1120,11 +1128,30 @@ tech_chi_fisher <- fisher.test(tech_table, simulate.p.value=TRUE) return(list(p1 = p1, tech_chi_fisher = tech_chi_fisher, tech_table = tech_table, - dat_tech1 = dat_tech1)) + tech_dat_long = tech_dat_long)) } +############################################################ +#' Combine raw materials and technology plots for upper-lens-lower +#' +#' +#' +#' @export +#' @examples +#' \dontrun{ +#' lens_tech_and_raw_plot <- combine_lens_plots(lens_differences_tech_plot$p1,lens_differences_raw_plot$p1) +#' } + +combine_lens_plots <- function(tech_dat_plot, raw_dat_plot) { + png("figures/Fig_10_combine_lens_plots.png",width=16, height=10, units="in", res=1200) + + gridExtra::grid.arrange(raw_dat_plot, tech_dat_plot) + + dev.off() + +} ############################################################ @@ -1737,7 +1764,7 @@ g <- ggplot(perc_and_mass_m, aes(Taxon, value)) + facet_grid(variable ~ Spit, scales = "free_y") # save plot as PNG -ggsave(file = "figures/shell_from_1989_for_paper.png", g) +ggsave(file = "figures/Fig_14_shell_from_1989_for_paper.png", g, dpi = 1200) return(g) diff --git a/man/combine_lens_plots.Rd b/man/combine_lens_plots.Rd new file mode 100644 index 0000000..c8e3e57 --- /dev/null +++ b/man/combine_lens_plots.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Please edit documentation in R/functions.R +\name{combine_lens_plots} +\alias{combine_lens_plots} +\title{Combine raw materials and technology plots for upper-lens-lower} +\usage{ +combine_lens_plots(tech_dat_plot, raw_dat_plot) +} +\description{ +Combine raw materials and technology plots for upper-lens-lower +} +\examples{ +\dontrun{ +lens_tech_and_raw_plot <- combine_lens_plots(lens_differences_tech_plot$p1,lens_differences_raw_plot$p1) +} +} + diff --git a/man/plots_lithics_data.Rd b/man/plots_lithics_data.Rd index ded67ff..150ae9f 100644 --- a/man/plots_lithics_data.Rd +++ b/man/plots_lithics_data.Rd @@ -11,7 +11,7 @@ Plots of the lithics raw data } \examples{ \dontrun{ -lithics_data_plotted <- plots_lithics_data(lithics_data, bayes_cp_result$cal.date.lo) +lithics_data_plotted <- plots_lithics_data(lithics_data_cleaned, bayes_cp_result$cal.date.lo) } } diff --git a/vignettes/analysis-of-dates-lithics-shell-from-1989-excavations.Rmd b/vignettes/analysis-of-dates-lithics-shell-from-1989-excavations.Rmd index 9eba69e..aa79849 100644 --- a/vignettes/analysis-of-dates-lithics-shell-from-1989-excavations.Rmd +++ b/vignettes/analysis-of-dates-lithics-shell-from-1989-excavations.Rmd @@ -134,7 +134,7 @@ bayes_slope_posteriors <- bayes_slope_difference(sed_rates_15_to_20_result$sub_O # from a run so we can use that rather than redo the analysis. To # redo the analysis, simply run the code in the previous chunk. load("data/slopes_test_sub.rda") -summary(slopes_test_sub) +BEST:::summary.BEST(slopes_test_sub) # print(slopes_test_sub) # plot(slopes_test_sub) # windows() @@ -159,15 +159,8 @@ lithics_data <- get_lithics_data() lithics_data_cleaned <- clean_lithics_data(lithics_data) ``` - -```{r get_interp, results='hide', include=FALSE} -# need these to get bayes_cp_result$cal.date.lo) -chrono_data_slopes_plot <- plotting_slopes_chrono_data(chrono_data_tidied) -bayes_cp_result <- bayes_cp_test(chrono_data_slopes_plot$dates_1989) -``` - ```{rplot-data} -lithics_data_plotted <- plots_lithics_data(lithics_data, bayes_cp_result$cal.date.lo) +lithics_data_plotted <- plots_lithics_data(lithics_data_cleaned, bayes_cp_result$cal.date.lo) lithics_data_plotted$p1 # figures/Fig_6_lithics_over_time_from_1989_for_paper.svg ``` @@ -183,22 +176,27 @@ lithics_rawmaterials_plotted <- plots_lithics_rawmaterials(lithics_data, ```{r strat-plot} lithics_rawmaterials_stratplotted <- stratiplot_lithics(lithics_rawmaterials_plotted$plot2) -# figures/stratplot.svg +# figures/Fig_9_stratplot.png ``` ```{r lens-raw-materials} lens_differences_raw_plot <- lens_differences_raw() -lens_differences_raw_plot$p1 raw_fish_pval <- formatC(round(lens_differences_raw_plot$raw_chi_fisher$p.value, 4), big.mark=",",format="f", drop0trailing = TRUE) ``` ```{r lens-tech-difference} lens_differences_tech_plot <- lens_differences_tech() -lens_differences_tech_plot$p1 tech_fish_pval <- round(lens_differences_tech_plot$tech_chi_fisher$p.value, 3) ``` +```{r lens-tech-and-raw-plot, results = "asis"} +lens_tech_and_raw_plot <- combine_lens_plots(lens_differences_tech_plot$p1,lens_differences_raw_plot$p1) +lens_tech_and_raw_plot +cat("
")
+```
+
+
Chi square tests indicate that the differences in raw material proportions between all three assemblages are highly significant (p = `r raw_fish_pval`), although the differences in technological composition are not significant (p = `r tech_fish_pval`), most likely due to small sample size (n = 10 for types in the assemblage below the lens).
diff --git a/vignettes/figures/Fig_10_combine_lens_plots.png b/vignettes/figures/Fig_10_combine_lens_plots.png
new file mode 100644
index 0000000..852a64b
Binary files /dev/null and b/vignettes/figures/Fig_10_combine_lens_plots.png differ
diff --git a/vignettes/figures/Fig_14_shell_from_1989_for_paper.png b/vignettes/figures/Fig_14_shell_from_1989_for_paper.png
new file mode 100644
index 0000000..4f38524
Binary files /dev/null and b/vignettes/figures/Fig_14_shell_from_1989_for_paper.png differ
diff --git a/vignettes/figures/Fig_5_MKII_dates_from_1989_for_paper.svg b/vignettes/figures/Fig_5_MKII_dates_from_1989_for_paper.svg
new file mode 100644
index 0000000..fa4fe39
--- /dev/null
+++ b/vignettes/figures/Fig_5_MKII_dates_from_1989_for_paper.svg
@@ -0,0 +1,832 @@
+
+
diff --git a/vignettes/figures/Fig_6_lithics_over_time_from_1989_for_paper.svg b/vignettes/figures/Fig_6_lithics_over_time_from_1989_for_paper.svg
index 2c3301c..8ab14b0 100644
--- a/vignettes/figures/Fig_6_lithics_over_time_from_1989_for_paper.svg
+++ b/vignettes/figures/Fig_6_lithics_over_time_from_1989_for_paper.svg
@@ -1,24 +1,24 @@
-