# ============================================== # Housesize & postdimensions of neolithic houses # ============================================== # encoding of the script: UTF-8, please check correct representation # Please set the working directory to the folder where the SQLite # database "jna_24_2022_Rinne_Suppl_3.sqlite" is stored. # required packages require (RSQLite) || install.packages("RSQLite") require (ggplot2) || install.packages("ggpot2") require (grid) || install.packages("grid") library(RSQLite) library(ggplot2) library(grid) #-------------------- # 1. house sizes lowlands and lower mountain range #-------------------- con<-dbConnect(SQLite(),"jna_24_2022_Rinne_Suppl_3.sqlite") house<-dbReadTable(con, "tbl_housesizes") #house <- na.omit(house) # convert region to factor with abbreviations: # MG: Mittelgebirgsraum, TL: Nordeuropäisches Tiefland house$region <- factor(house$region, levels = c("Mittelgebirgsraum", "Nordeuropäisches Tiefland"), labels=c("MG", "TL")) table(house$region) # convert period to ordered factor with abbreviation house$period <- factor(house$period, levels = c("Frühneolithikum", "Mittelneolithikum", "Jungneolithikum", "Spätneolithikum", "Endneolithikum", "Frühbronzezeit"), labels = c("FN", "MN", "JN", "SN", "EN", "FBZ"), order=TRUE) table(house$period) # create groups for regional periods and correct labeling # table(paste(house$period, house$region, sep="-")) house$reg.period<-paste(house$period, house$region, sep="-") house$reg.period<-ordered(house$reg.period, levels = c("FN-MG", "MN-MG", "JN-MG", "JN-TL", "SN-MG", "SN-TL", "EN-MG", "EN-TL", "FBZ-MG")) levels(house$reg.period)[levels(house$reg.period)=="JN-TL"] <- "FN-TL" levels(house$reg.period)[levels(house$reg.period)=="SN-TL"] <- "MN-TL" levels(house$reg.period)[levels(house$reg.period)=="EN-TL"] <- "SN-TL" table(house$reg.period) # create plot for the northern lowlands and the lower mountain range # house 1 from Mairy-Hautes Chanvières with 683 m² will be excluded house[house$sqm>600,] # add the number of houses for x-labels t.faelle<-table(house$reg.period[house$sqm<600]) x.labels<-paste(names(t.faelle), as.integer(t.faelle), sep = "\n") ggplot(house[house$sqm<600,], aes(x=reg.period, y=sqm, fill=reg.period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + scale_x_discrete(labels = x.labels) + ylab('Hausgröße (m²)') + xlab('Periode & Region') #---------------------------------------- # 2. housesize lower mountain range only #----------------------------------------- houseMG<-subset(house, house$region == "MG") t.faelleMG<-table(houseMG$period) x.labelsMG<-paste(names(t.faelleMG), as.integer(t.faelleMG), sep = "\n") # one house from Mairy with 683 m² will be excluded ggplot(houseMG[houseMG$sqm<600,], aes(x=period, y=sqm, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + scale_x_discrete(labels = x.labelsMG) + ylab('Hausgröße (m²)') + xlab('Periode & Anzahl') # plot for stacking p.houses<-ggplot(houseMG[houseMG$sqm<600,], aes(x=period, y=sqm, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + ylab('Hausgröße (m²)') + theme(axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) #-------------------- # 3. posts dimensions #-------------------- post<-dbReadTable(con, "tbl_postslabled") # convert region to factor with abbreviations: # MG: Mittelgebirgsraum, TL: Nordeuropäisches Tiefland post$region <- factor(post$region, levels = c("Mittelgebirgsraum", "Nordeuropäisches Tiefland"), labels=c("MG", "TL")) table(post$region) # convert period to ordered factor with abbreviation post$period <- factor(post$period, levels = c("Frühneolithikum", "Mittelneolithikum", "Jungneolithikum", "Spätneolithikum", "Endneolithikum", "Frühbronzezeit"), labels = c("FN", "MN", "JN", "SN", "EN", "FBZ"), order=TRUE) table(post$period) t.faelle<-table(post$period) x.labels<-paste(names(t.faelle), as.integer(t.faelle), sep = "\n") ggplot(post, aes(x=period, y=sqm, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + scale_x_discrete(labels = x.labels) + ylab('Pfostengrube (m²)') + xlab('Periode & Anzahl') #plot for stacking p.posts<-ggplot(post, aes(x=period, y=sqm, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + ylab('Pfostengrube (m²)') + theme(axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) # -------------------------------------------------- # 4. Posts and housesize # -------------------------------------------------- ch <- dbReadTable(con, "tbl_houseposts") # convert region to factor with abbreviations: # MG: Mittelgebirgsraum, TL: Nordeuropäisches Tiefland ch$region <- factor(ch$region, levels = c("Mittelgebirgsraum", "Nordeuropäisches Tiefland"), labels=c("MG", "TL")) table(ch$region) # convert period to ordered factor with abbreviation ch$period <- factor(ch$period, levels = c("Frühneolithikum", "Mittelneolithikum", "Jungneolithikum", "Spätneolithikum", "Endneolithikum", "Frühbronzezeit"), labels = c("FN", "MN", "JN", "SN", "EN", "FBZ"), order=TRUE) table(ch$period) # calculate: ch$ch.np<-ch$convexhull/ch$count_posts # sqm convex hull / count postholes ch$ch.ap<-ch$convexhull/ch$sqm_posts # sqm convex hull / sqm all postholes # Two houses will be excluded due to very extreme values # reconstruction by posts might be questioned ch[ch$ch.ap>200,] t.faelle<-table(ch$period[ch$ch.ap<200]) x.labels<-paste(names(t.faelle), as.integer(t.faelle), sep = "\n") # plot of proportion of convex hull posts / sqm of all postholes ggplot(ch[ch$ch.ap<200,], aes(x=period, y=ch.ap, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + scale_x_discrete(labels = x.labels) + ylab(paste ('Postenareal (m²) /', 'Summe Pfostenfläche (m²)', sep='\n')) + xlab('Periode & Anzahl') # plot for stacking p.ap <- ggplot(ch[ch$ch.ap<200,], aes(x=period, y=ch.ap,fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + ylab(paste ('Postenareal (m²) /', 'Summe Pfostenfläche (m²)', sep='\n')) + theme(axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) # plot of proportion of convex hull posts / count postholes ggplot(ch[ch$ch.ap<200,], aes(x=period, y=ch.np, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + scale_x_discrete(labels = x.labels) + ylab (paste ('Postenareal (m²) /', 'Anzahl Pfosten', sep = '\n')) + xlab('Periode & Anzahl') # create a plot with simple x-labeling p.npx <- ggplot(ch[ch$ch.ap<200,], aes(x=period, y=ch.np, fill=period)) + stat_boxplot(geom='errorbar') + geom_boxplot() + scale_fill_brewer(palette = "Paired", guide="none") + ylab (paste ('Postenareal (m²) /', 'Anzahl Pfosten', sep = '\n')) + xlab('Periode') # ------------------------------ # putting the plots together # ------------------------------ grid.newpage() grid.draw(rbind( ggplotGrob(p.houses), ggplotGrob(p.posts), ggplotGrob(p.ap), ggplotGrob(p.npx), size="last" ))