ConSciR

Introduction

ConSciR is an R package specifically designed to assist conservators, scientists, and engineers by providing a toolkit for performing calculations and streamlining common tasks in cultural heritage conservation.

Install and load

You can install the development version of the package from GitHub using either the pak or devtools package:

install.packages("pak")
pak::pak("BhavShah01/ConSciR")

-or-

# install.packages("devtools")
devtools::install_github("BhavShah01/ConSciR")

Visit the package GitHub page for updates and source code: ConSciR Github

Examples

Load the necessary packages:

# Load packages
library(ConSciR)
library(dplyr)
library(ggplot2)

Add calculated values using mutate

Enrich your dataset with environmental metrics computed by ConSciR functions:

filepath <- data_file_path("mydata.xlsx")
mydata <- readxl::read_excel(filepath, sheet = "mydata")
mydata <- mydata |> filter(Sensor == "Room 1")


# Add calculated values using mutate
head(mydata) |> 
  mutate(
    Absolute_Humidity = calcAH(Temp, RH), 
    Dew_Point = calcDP(Temp, RH), 
    Mixing_Ratio = calcMR(Temp, RH), 
    Humidity_Ratio = calcHR(Temp, RH),
    Enthalpy = calcEnthalpy(Temp, RH), 
    Saturation_Vapour_Pressure = calcPws(Temp), 
    Actual_Vapour_Pressure = calcPw(Temp, RH), 
    Air_Density = calcAD(Temp, RH),
    Temp_calc = calcTemp(RH, Dew_Point),
    RH_AH_calc = calcRH_AH(Temp, Absolute_Humidity),
    RH_DP_calc = calcRH_DP(Temp, Dew_Point)
  ) |>
  glimpse()
#> Rows: 6
#> Columns: 16
#> $ Site                       <chr> "London", "London", "London", "London", "Lo…
#> $ Sensor                     <chr> "Room 1", "Room 1", "Room 1", "Room 1", "Ro…
#> $ Date                       <dttm> 2024-01-01 00:00:00, 2024-01-01 00:15:00, …
#> $ Temp                       <dbl> 21.8, 21.8, 21.8, 21.7, 21.7, 21.7
#> $ RH                         <dbl> 36.8, 36.7, 36.6, 36.6, 36.5, 36.2
#> $ Absolute_Humidity          <dbl> 7.052415, 7.033251, 7.014087, 6.973723, 6.9…
#> $ Dew_Point                  <dbl> 6.383970, 6.344456, 6.304848, 6.216205, 6.1…
#> $ Mixing_Ratio               <dbl> 5.957278, 5.940935, 5.924593, 5.888156, 5.8…
#> $ Humidity_Ratio             <dbl> 5.957278, 5.940935, 5.924593, 5.888156, 5.8…
#> $ Enthalpy                   <dbl> 37.15665, 37.11512, 37.07359, 36.87888, 36.…
#> $ Saturation_Vapour_Pressure <dbl> 26.12119, 26.12119, 26.12119, 25.96205, 25.…
#> $ Actual_Vapour_Pressure     <dbl> 9.612598, 9.586477, 9.560356, 9.502110, 9.4…
#> $ Air_Density                <dbl> 1.192445, 1.192457, 1.192469, 1.192899, 1.1…
#> $ Temp_calc                  <dbl> 21.8, 21.8, 21.8, 21.7, 21.7, 21.7
#> $ RH_AH_calc                 <dbl> 36.8, 36.7, 36.6, 36.6, 36.5, 36.2
#> $ RH_DP_calc                 <dbl> 36.8, 36.7, 36.6, 36.6, 36.5, 36.2

Visualise and explore data with calculations

Combine calculations and plotting to explore patterns visually:


mydata |>
  # Calculate Absolute Humidity and Dew Point
  mutate(
    AbsHum = calcAH(Temp, RH),
    DewPoint = calcDP(Temp, RH)
  ) |>
  # Create base plot using graph_TRH function
  graph_TRH() +
  # Add Absolute Humidity line
  geom_line(aes(Date, AbsHum), color = "green") +
  # Add Dew Point line
  geom_line(aes(Date, DewPoint), color = "purple") +
  # Apply a theme
  theme_bw()

visualisations

mydata |>
  mutate(Mould = calcMould_VTT(Temp, RH)) |>
  ggplot() +
  geom_area(aes(Date, Mould), fill = "darkgreen", alpha = 0.5) +
  labs(title = "Mould Growth Index", 
       y = "Mould Index") + 
  theme_classic()

mould

Built-in psychrometric chart

Visualise the first 100 rows of the dataset with a psychrometric chart:


head(mydata, 100) |>
  graph_psychrometric() + 
  theme_bw()

psychrometric_chart_example

Psychrometric Chart Customisation

Create tailored psychrometric charts by adjusting parameters such as temperature and humidity ranges, visual transparency, or y-axis metrics:


head(mydata, 100) |>
  graph_psychrometric(
    LowT = 10, 
    HighT = 28,
    LowRH = 20, 
    HighRH = 80,
    data_alpha = 0.3,
    y_func = calcAH
  ) + 
  theme_classic()

psychrometric_chart_custom


This vignette provides a practical introduction to the package’s core functionalities. For full details on all functions, see the package Reference manual or use ?function_name within R.