This code is the R version of the online calculator available on helioreflect.com.
You just need to download the R program here to run this file.
The computation uses the typical meteorological year of PVGIS.CO2 estimations for electricity comes from electricitymap.org.
Glazing transmissivity here.
Some code lines come from cerebralmeltdown.com.