## ----setup, include=FALSE----------------------------------------------------- #knitr::opts_chunk$\alphaet(echo = FALSE) knitr::opts_chunk$set(message = FALSE, eval=FALSE) knitr::opts_chunk$set(fig.align = "center") #solo para html knitr::opts_chunk$set(fig.width = 8) knitr::opts_chunk$set(dpi = 1200) ## ----echo=TRUE, warning=FALSE, message=FALSE---------------------------------- # library(RIFanalysis) ## ----------------------------------------------------------------------------- # # library(readr) # data_gr1 <- read.csv("0_data_gr1.csv") # data_gr2 <- read.csv("0_data_gr2.csv") ## ----------------------------------------------------------------------------- # # Review required variable names (ALWAYS verify them in the dataset) # fact_lbl_prefix1 <- "gr1T" # Choose according to your needs (gr=group, T=topic, C=concept, F=factor, I=index, etc.) # var_factor_name1 <- "factor1" # Long/original FACTOR variable # var_factor_small1 <- "factor_small1" # Short FACTOR variable # var_factor_label_small1 <- "factor_label_small1" # FACTOR_label_small variable # var_count_name1 <- "count1" # COUNT variable # # fact_lbl_prefix2 <- "gr2T" # Choose according to your needs (gr=group, T=topic, C=concept, F=factor, I=index, etc.) # var_factor_name2 <- "factor2" # Long/original FACTOR variable # var_factor_small2 <- "factor_small2" # Short FACTOR variable # var_factor_label_small2 <- "factor_label_small2" # FACTOR_label_small variable # var_count_name2 <- "count2" # COUNT variable # # # Identify the Type column available in each input dataset # var_type_name1 <- "type1" # Change # var_type_name2 <- "type2" # Change # # # Assign labels identifying the groups to be compared because the datasets do not contain a Group variable # gr_value_name1 <- "gr1_NAME" # Change (Colombia, Greece, Blue Economy, etc.) # gr_value_name2 <- "gr2_NAME" # Change (Colombia, Greece, Blue Economy, etc.) # #prefix_name <- paste0(gr_name, "_") # # #________________________________________________________________________ # # # # # If desired, change axis title for RIF matrices (Topic, Concept, Factor, etc.) and labels. # # IN rif_workflow_z3, SEE plot_matrix.R FUNCTION: # # # Axis title: # x_title_name <- "s: CHANGE_NAME at rank s" # default: Concept # y_title_name <- "r: CHANGE_NAME at rank r" # default: Concept # # Axis labels: # factor_r_label_col_name <- "Factor_label" # default: factor_r_label_col = NULL # factor_s_label_col_name <- "Factor_label" # default: factor_s_label_col = NULL # # #________________________________________________________________________ # # # # # Change titles for power-law plots (used in rif__workflow_z1 and plot_zipf) # #title default is "Observed and theoretical Zipf distributions..." # title_plotzipf_gr1_c2 <- "GROUPNAME1" # Change if desired # title_plotzipf_gr2_c2 <- "GROUPNAME2" # Change if desired # # x_title_plotzipf_c2 <- "Position" # Change if desired (default="Rank") # y_title_plotzipf_c2 <- "Frequency" # Change if desired (default="Count") # # #________________________________________________________________________ # # # # # Change custom file names (if desired) # file_prefix_no_title <- "zipf_notitle" # file_prefix_yes_title_c1 <- "zipf_yestitle_c1" # file_prefix_yes_title_c2 <- "zipf_yestitle_c2" # # # Change output directories (if desired) # output_dir_personal <- file.path(tempdir(), "Z0_personal") # output_dir_comparison <- file.path(tempdir(), "Z2_RIF_comparison") # output_dir_visual <- file.path(tempdir(), "Z3_RIF_visual") ## ----------------------------------------------------------------------------- # rif_data1 <- rif_prepare(data= data_gr1, # factor_col = var_factor_name1, # count_col = var_count_name1, # factor_small_col = var_factor_small1, # group_col = NULL, # type_col = var_type_name1, # group_value = gr_value_name1, # type_value = var_type_value_name1, # prefix = fact_lbl_prefix1, # factor_small_label_style = "inline") # # rif_data1 # names(rif_data1) ## ----------------------------------------------------------------------------- # rif_data2 <- rif_prepare(data= data_gr2, # factor_col = var_factor_name2, # count_col = var_count_name2, # factor_small_col = var_factor_small2, # group_col = NULL, # type_col = var_type_name2, # group_value = gr_value_name2, # type_value = var_type_value_name2, # prefix = fact_lbl_prefix2, # factor_small_label_style = "inline") # # rif_data2 # names(rif_data2) ## ----------------------------------------------------------------------------- # z2 <- rif_workflow_z2( # rif_data1= rif_data1, # rif_data2= rif_data2, # alpha_zipf = 1, # no_of_sims = 1000, # threads = 8, # seed = 123, # bootstrap_engine = "poweRlaw", # output_dir = output_dir_comparison, # plot_formats = c("png", "pdf") # ) ## ----eval=FALSE--------------------------------------------------------------- # # Original input objects # z2$input1 # z2$input2 # # # Input object classes # z2$input_class1 # z2$input_class2 # # # Prepared datasets # z2$data1 # z2$data2 # # # Descriptive Zipf tables # z2$zipf1 # z2$zipf2 # # # Power-law analysis (`plreg`) objects # z2$analysis1 # z2$analysis2 # # # RIF result objects # z2$rif_results1 # z2$rif_results2 # # # Comparative RIF results # z2$rif_comparison # # # Generated plots # z2$plots # # # Exported files and directories # z2$files ## ----------------------------------------------------------------------------- # rif_workflow_z3( # x = z2$rif_comparison, # scope = "combined", # plot_types = c("matrix", "network"), # formats = c("png", "pdf"), # #plot_types = "matrix", # output_dir = output_dir_visual, # # #SEE plot_matrix.R FUNCTION: # matrix_args = list( # #factor_r_label_col = factor_r_label_col_name, # factor_s_label_col = factor_s_label_col_name, # x_title = x_title_name, # y_title = y_title_name # ) # ) ## ----------------------------------------------------------------------------- # # Individual group plots # z2$plots$group1 # z2$plots$group2 # # # File information for Group 1 # z2$files$group1 # # # File information for Group 2 # z2$files$group2 # # # All generated plot files # z2$files$plots # # # Comparative Excel file # z2$files$excel # #