##Triple Helix Calculation for 4 Variables
#Ed Lefley
#Shawn Leu
#2021 12 02
#2021 12 08
#2021 12 10
#2022 01 19 Added Overseas and changed to using full dataset

#Based on Leydesdorff's original calculations
#Expanded using Hu et al (2021)
library(stringr)

library(data.table)

#Don't run everytime - only run on initial set up
#Ag7_TH_M_TH_SS$TH_NN <- (ifelse(Ag7_TH_M_TH_SS$TH_F == 1, 1,
#                                ifelse(Ag7_TH_M_TH_SS$TH_S ==1, 1,
#                                       0)))

Entropy_Ag7_5 <- as.data.frame(paste(Ag7_TH_M_TH_SS$TH_U,
                                     Ag7_TH_M_TH_SS$TH_I,
                                     Ag7_TH_M_TH_SS$TH_G,
                                     Ag7_TH_M_TH_SS$TH_S,
                                     Ag7_TH_M_TH_SS$TH_F,
                                   sep = ","))
colnames(Entropy_Ag7_5) <- c("Set")
Ag7_TH_M_TH_SS_5 <- cbind(Ag7_TH_M_TH_SS, Entropy_Ag7_5)
#248,645

Ag7_TH_M_TH_SS_5 <- subset(Ag7_TH_M_TH_SS_5, Set != "0,0,0,0,0") #removes 
Ag7_TH_M_TH_SS_5 <- subset(Ag7_TH_M_TH_SS_5, Set != "0,0,0,1,1") #removes 17
Ag7_TH_M_TH_SS_5 <- subset(Ag7_TH_M_TH_SS_5, Set != "0,0,0,1,0") #removes 35
Ag7_TH_M_TH_SS_5 <- subset(Ag7_TH_M_TH_SS_5, Set != "0,0,0,0,1") #removes 51

#Import the total numbers from all years, recorded for PRISMA Statement
#Ag7_Total <-read.csv("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7/Ag7_Total_Pubs.csv")

#Now run year by year
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2003_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_10_31_Entropy5_2004_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_10_31_Entropy5_2005_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2006_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2007_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2008_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2009_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2010_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2011_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2012_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2013_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2014_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2015_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2016_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2017_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2018_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_03_25_Entropy5_2019_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_10_31_Entropy_Graph_LL_Ag7.R")
setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("2022_05_19_Quin_Diagrams.R")

setwd("C:/Users/Ed/OneDrive/PhD/R/2022_Ag7")
source("rs2022_09_26_TValue_Diags.R")

