table1_script.R 1.21 KB
Newer Older
pxp9's avatar
pxp9 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42


rm(list=ls())

setwd("C:/Users/victor/Documents/TFG/r-analytics-master")

#Obtain the data from the codebook
codebook <- read.csv("harmon.csv", sep = ";")
codebook <- codebook[,c(1,3,4)]
colnames(codebook) <- c("variable", "description", "unit")

source("dependency_installer.R")
source("connection_parameters_aux.R")
source("necessary_functions_table1_v2_subset.R")

dep_list = c("DSI","DSOpal","DSLite", "dsBaseClient")
install_dependencies(dep_list)

dir.create("./table_1", showWarnings = FALSE)
setwd("./table_1")


#Create the connection
auxConnections <- connect()
connections <- auxConnections[[1]]
inp <- auxConnections[[2]]

#Only do this if you want to subset the data for a specific value of a categoric variable
apply_filters()

#Select the variables to be analized (Add the ones you consider relevant and remove the ones that you do not)
varToAnalize <- c("DMRGENDR","DMRAGEYR","DSXOS", "RFXSM", "TRXAV",  "CMXCVD", "RFXOB")
varToAnalize <- c("DMRGENDR","DMRAGEYR")

table1 <- obtain_table1(connections, inp, varToAnalize)

#datashield.logout(connections)

library(gridExtra)
png("table1TFGFiltro.png", height = 30*nrow(table1), width = 150*ncol(table1))
grid.table(table1)
dev.off()