drndr/statcodesearch huggingface dataset:
File: multipleChoiceSame.R

Comment: for loop goes through all the files in myLists and applies addTagsTextEntry to each row in the file
Category: Data Variable
Code:
for (k in 1:length(myLists)) { i <- paste("list", k, ".txt", sep = "") o <- paste("upload", k, ".txt", sep = "") f <- read.delim(i, header = FALSE, stringsAsFactors = FALSE) write("[[AdvancedFormat]]", o) apply(f, 1, addMultiChoiceSame, o) } rm(list=ls())
File: Lissonetal2021-script.R

Comment:  compute mean LT per condition, group and accuracy 
Category: Data Variable
Code:
LT <- ddply(data, .(rctype,group,acc_lab), summarize, mean.rt = mean(rt), se.lower = mean.rt - se(rt), se.upper = mean.rt + se(rt))
File: SSSS-Latent Variable Analysis Made Easy (1.0) .R

Comment: Fit uni.cfa and save output in uni.cfi.fit. Use fixed factor (std.lv  TRUE), and FIML for missing data) 
Category: Statistical Modeling
Code:
uni.cfa.fit = cfa(uni.cfa, data = SSSSdat, std.lv = TRUE, missing = "ML")

Comment: Request summary output from model, including fit indexes, standardized estimates, and R^2/communalities 
Category: Statistical Modeling
Code:
summary(uni.cfa.fit, fit.measures = TRUE, standardized = TRUE, rsquare=TRUE) summary(five.cfa.fit, fit.measures = TRUE, standardized = TRUE, rsquare=TRUE) summary(five.sem.parcel.corr.fit, fit.measures = TRUE, standardized = TRUE, rsquare=TRUE) summary(five.sem.parcel.reg.fit, fit.measures = TRUE, standardized = TRUE, rsquare=TRUE)

Comment: We need to get an idea of how many factors are likely needed. Parallel analysis can help. Save output in object "parallel", using psych() fa.parallel function. Variables 125 (the BFI items) are to be analzyed, using maximum likelihood (ml) common factors (fa). Simulate 50 other samples of "garbage factors", using R^2s (SMC) as initial communality estimates and compare observed eigenvalues to 95th quantile of simulated "garbage factor" eigenvalues 
Category: Statistical Modeling
Code:
parallel = fa.parallel(SSSSdat[1:25], fm = 'ml', fa = 'fa', n.iter = 50, SMC = TRUE, quant = .95)

Comment: Fit measurement invariance models based on five.cfa model, distinguishing by group levels of "gender". Save output in invar.output object 
Category: Statistical Modeling
Code:
invar.output = measurementInvariance(five.cfa, data = SSSSdat, group = "gender")
File: Syntax_Sibpaper1_final_2021-02-12.R

Comment: Create function to calculate ICC from fitted model: ICC  between family variance / total family variance
Category: Statistical Modeling
Code:
calc.icc <- function(y) { sumy <- summary(y) (sumy$varcor$famnumber[1]) / (sumy$varcor$famnumber[1] + sumy$sigma^2) } calc.icc <- function(y) { sumy <- summary(y) (sumy$varcor$famnumber[1]) / (sumy$varcor$famnumber[1] + sumy$sigma^2) }
File: analysis_mmreg.R

Comment: ** 5.2) Poisson regression   **** 5.2.1) Full set   model 1: summary effect (absolute value)
Category: Statistical Modeling
Code:
pred.nbias.1 <- glm(nmeth_bias ~ scale(abs(MA_ES_self)), data = dat[!is.na(nmeth_bias) & k_self > k_thres, ], family = poisson) summary(pred.nbias.1) rsq.pred.nbias.1 <- logisticPseudoR2s(pred.nbias.1)
File: Descriptives_Tables_1_2_S1_S2.R

Comment:  ANOVA dependent variable: drift rate independent variable:masking time condition  letters task, pretest 
Category: Data Variable
Code:
cv_pre_drift = cogito %>% gather(key = "maskingtime", value = "drift", cvt1_v1,cvt1_v2,cvt1_v3,cvt1_v4) %>% convert_as_factor(obs, maskingtime) aov_cv_pre <- anova_test(data = cv_pre_drift , dv = drift, wid = obs, within = maskingtime, type=3, detailed=T) get_anova_table(aov_cv_pre, correction="none")
File: RAQ-R_reliability after exclusion.R

Comment: subsample of the PG without patients with schizophrenia or other psychotic disorders (F20. or F23.)
Category: Data Variable
Code:
subsample_PGwithoutF20_23 <- subsample_PG[subsample_PG$F20_23==0, ]
File: Descriptives_Selfreports.R

Comment: calculate intercorrelations between diamonds on the betweenperson level with 95% Bootstrapped CI
Category: Statistical Test
Code:
between.person.diamonds = diamonds %>% group_by(user_id) %>% summarise(across(where(is.numeric), ~ mean(.x))) between.person.diamonds = between.person.diamonds %>% dplyr::select(diamonds_duty, diamonds_intellect, diamonds_adversity, diamonds_mating, diamonds_positivity, diamonds_negativity, diamonds_deception, diamonds_sociality) cors.diamonds = round(cor(between.person.diamonds, method = "pearson"),2) cors.diamonds = as.data.frame(cors.diamonds)
File: Gatekeeper analysis.r

Comment: Analysis  Linear Probability Model on Impact Factor
Category: Statistical Modeling
Code:
fit_ev_if <- lm(X1.year.Impact.Factor ~ diff_ev + factor(year), data=FullDataset) summary(fit_ev_if) # show results fit_ex_if <- lm(X1.year.Impact.Factor ~ diff_ex + factor(year), data=FullDataset) summary(fit_ex_if) # show results

Comment: Tobit Model as robusntess check  assign value 0 to Impact factors for unpublished studies
Category: Statistical Modeling
Code:
FullDataset$X1.year.Impact.Factor[FullDataset$published == "No"] = 0 tobit_ev_if <- censReg( X1.year.Impact.Factor ~ diff_ev + factor(year), data = FullDataset, left = 0) summary(tobit_ev_if) tobit_ex_if <- censReg( X1.year.Impact.Factor ~ diff_ex + factor(year), data = FullDataset, left = 0) summary(tobit_ex_if)
File: AnalysisScript-ResearchQuestion1.R

Comment: initialize standard error function
Category: Data Variable
Code:
stderr <- function(x, na.rm=FALSE) { if (na.rm) x <- na.omit(x) sqrt(var(x)/length(x)) }

Comment: 2019 data  zstandardize mood scores for each person
Category: Data Variable
Code:
dat2019_scaled <- dat2019_complete %>% dplyr::select(identity_id, country, doy, mood, weekday) %>% group_by(identity_id)  %>% mutate_at(vars(-identity_id,-doy,-country, -weekday), scale)

Comment: Run regression anlayses and save as table (make one table with mood and depression  see depression section)
Category: Statistical Modeling
Code:
m1_het <- lm(mood_change ~ gender + age + education_level + race, data = dat_het_prepost) m2_het <- lm(depression_change ~ gender + age + education_level + race, data = dat_het_prepost) tab_model(m1_het, m2_het, show.est = F, show.std = T, digits = 3, file="Mood_Depression_PrePost_Demog_std.doc")

Comment: Run multilevel model analyses predicting mood scores from the the dummycoded month variable
Category: Statistical Modeling
Code:
dat2020_complete$month <- as.factor(dat2020_complete$month) summary(m1 <- lmer(depression ~ month + (1|identity_id), data = subset(dat2020_complete, country == "United States"))) summary(m2 <- lmer(depression ~ month + (1|identity_id), data = subset(dat2020_complete, country == "Germany"))) summary(m3 <- lmer(depression ~ month + (1|identity_id), data = subset(dat2020_complete, country == "United Kingdom"))) tab_model(m1,m2,m3, show.est = F, show.std = T, digits = 3, file="Depression_2020_Months.doc")
File: ThesisMLROCCode.R

Comment: Step 2: Create onehot encodings (dummy variables)
Category: Data Variable
Code:
testData3 <- predict(dummies_model, testData2) testData3 <- predict(dummies_model, testData2) testData3 <- predict(dummies_model, testData2) testData3 <- predict(dummies_model, testData2) testData3 <- predict(dummies_model, testData2)
File: 4_4_identification.R

Comment:  function to generate output csv files for a list of response IDs  inputs: dataset, list of response IDs  outputs: csv files named with response IDs 
Category: Visualization
Code:
multi_response <- function(dataset, IDs_list) { for (i in IDs_list) { participant_response <- single_response(dataset, i) csv_name <- str_c(i, ".csv", sep = "") write.csv(participant_response, csv_name) } }
File: PREPROC_script_Experiment1.r

Comment: Means and SDs of proportional looking time to novel object in the preferential looking phase  condition 1
Category: Data Variable
Code:
mean(dfX_base$PrefLook_LT_Object_Nov_PROP[which(dfX_base$Condition == "Con1")], na.rm = TRUE)
File: helper_variables.R

Comment: calculate mode of a vector
Category: Statistical Modeling
Code:
mode.knn =  function(x){ uniq.x = unique(x) uniq.x = uniq.x[which(!is.na(uniq.x))] knn = uniq.x[which.max(tabulate(match(x, uniq.x)))] return(knn) }

Comment: find [k] neigherst neigbors and impute by their mode
Category: Statistical Modeling
Code:
impute.knn = function(y, k){ t = which(is.na(y)) if(length(t) == 0){ return(y) }else{ is = 1:length(t) for(i in is){ if(i > k){ look.at = y[(t[i]-k):(t[i]+k)] y[t[i]] = mode.knn(look.at) } if(i <= k){ look.at = y[1:(t[i]+k)] y[t[i]] = mode.knn(look.at) } } return(y) } }
File: mplus.R

Comment: get categorical data information then look up the variables in the process  in categorical_data so we can get the number of categories for each variable in the process  this would be achieved by categories[cat_indices[i]] for variable i in the process
Category: Data Variable
Code:
categories <- as.integer(mplus.get.group.attribute(file,'categorical_data','categories')) catvars <- mplus.get.group.attribute(file,'categorical_data','var_names') vartypes <- as.integer(mplus.get.group.attribute(file,'categorical_data','vtype')) if (series) { categories <- as.integer(mplus.get.group.attribute(file,'categorical_data','categories')) catvars <- mplus.get.group.attribute(file,'categorical_data','var_names') vartypes <- as.integer(mplus.get.group.attribute(file,'categorical_data','vtype')) if (series) {

Comment: get indices and names of the variables in the series
Category: Data Variable
Code:
var_indices <- mplus.get.group.attribute(file,cstr2,'var_indices') var_names <- mplus.get.group.attribute(file,cstr2,'var_names') cat_indices <- pmatch(var_names, catvars, nomatch=0) cat_indices <- as.integer(cat_indices) var_indices <- mplus.get.group.attribute(file,cstr2,'var_indices') var_names <- mplus.get.group.attribute(file,cstr2,'var_names') cat_indices <- as.integer(pmatch(var_names, catvars, nomatch=0))
File: 02_IML_LASSO_FeatImp.R

Comment: extract correlations between selfreported scores (observational level!)
Category: Data Variable
Code:
self.reported.scores = c("duty", "intellect", "mating", "positivity", "sociality") l = "mating" for(i in self.reported.scores[1:length(self.reported.scores)-1]){ data_phi = ftable(data[,c(paste0("diamonds_", l), paste0("diamonds_", self.reported.scores[which(self.reported.scores == i)+1]))]) print(paste(l, "and", self.reported.scores[which(self.reported.scores == i)+1])) print(phi(data_phi)) }
File: TSST_Meta.R

Comment: generate unique study identifier, format and annotate data 
Category: Data Variable
Code:
d$id <- paste0(d$First_Author,", ", d$Year) d$Year <- as.numeric(substr(d$Year,1,4)) d$ids <- NA for(i in d$id) d[d$id == i,"ids"] <- 1:dim(d[d$id == i,"ids"])[1] d$ids <- as.character(d$ids) d$Age <- (as.numeric(d$Age_M) - 30) / 20 d$energy_renew <- d$energy_renew1 + d$energy_renew2 find_cCode <- Vectorize(function(i) which(unlist(Map(function(x) sum(d[i,grepl("SVS",names(d))] - f[x,grepl("SVS",names(f))]), 1:dim(f)[1])) == 0)) d$Ccode <- f$Ccode[find_cCode(1:dim(d)[1])]
File: create_model_formulas.R

Comment:  to make sure that effects are tested from complex to simple, we reverse the order of the vector containing the to be tested effects: 
Category: Data Variable
Code:
effects_to_test = rev(effects_to_test)

Comment: combine model matrix and data to include participant id and DV:
Category: Data Variable
Code:
new_data = data.frame(dplyr::select(data, contains(c(group, DV_variables, by))), model_matrix)
File: sanet_2.R

Comment: check if retention is a number from 0 to 1
Category: Data Variable
Code:
if (retention < 0 || retention > 1) { stop('Retention value is not a number from 0 to 1.') }
File: Exp2_BehaviouralAnalyses_Code.R

Comment:  construct a maximal glmer() model  This model contains code for Ambiguity effect,  plus random effects by participants and items. 
Category: Statistical Modeling
Code:
Acc.Modality.max <- glmer(Correct ~ 1 + Ambiguity.code + (1 + Ambiguity.code | Ã¯..ID) + (1   | Item), data = Data.DisambTask.AmbvsUnamb, family = "binomial", control = glmerControl(optimizer ="bobyqa"))

Comment: create a histogram of the residuals
Category: Visualization
Code:
hist(rawResiduals) hist(invResiduals) hist(logResiduals)

Comment: construct a maximal lmer() model  This model contains a fixed withinsubjects effect of Ambiguity (effectcoded with 0.5 amb)  plus random effects by participants and items.
Category: Statistical Modeling
Code:
RT.max <- lmer(logRT ~ 1 + Ambiguity.code + (1 + Ambiguity.code | Ã¯..ID) + (1   | Item), data = Data.DisambTask.AmbvsUnamb, REML=FALSE)

Comment:  construct a maximal glmer() model  This model contains codes for Modality effects,  plus random effects by participants and items. 
Category: Statistical Modeling
Code:
Acc.Modality.max <- glmer(Correct ~ 1 + Modality.code1 + Modality.code2 + (1 + Modality.code1 + Modality.code2 | Ã¯..ID) + (1   | Item), data = Data.DisambTask.Amb, family = "binomial", control = glmerControl(optimizer ="bobyqa")) Acc.Modality.max <- glmer(True.Positive ~ 1 + Modality.code2 + (1 + Modality.code2 | ID) + (1   | Item), data = Data.ListAndRead, family = "binomial", control = glmerControl(optimizer ="bobyqa")) Acc.Modality.max <- glmer(True.Positive ~ 1 + Modality.code3 + (1 + Modality.code3 | ID) + (1   | Item), data = Data.ListAndRSVP, family = "binomial", control = glmerControl(optimizer ="bobyqa")) Acc.Modality.max <- glmer(True.Positive ~ 1 + Modality.code3 + (1 + Modality.code3 | ID) + (1   | Item), data = Data.ReadAndRSVP, family = "binomial", control = glmerControl(optimizer ="bobyqa"))

Comment:  construct a maximal glmer() model  This model contains codes for run effects,  plus random effects by participants and items. 
Category: Statistical Modeling
Code:
Acc.Run.max <- glmer(Correct ~ 1 + Run.code1 + Run.code2 + (1 + Run.code1 + Run.code2 | Ã¯..ID) + (1   | Item), data = Data.DisambTask.Amb, family = "binomial", control = glmerControl(optimizer ="bobyqa")) Acc.Run.max <- glmer(True.Positive ~ 1 + Run.code1 + Run.code2 + (1 + Run.code1 + Run.code2 | ID) + (1   | Item), data = Data.RecMem, family = "binomial", control = glmerControl(optimizer ="bobyqa"))

Comment: run a onesample ttest comparing accuracy to chance level (0.5)
Category: Statistical Test
Code:
t.test(Data.List$True.Positive, mu=0.5) t.test(Data.Read$True.Positive, mu=0.5) t.test(Data.RSVP$True.Positive, mu=0.5)
File: scrape_web_pages.R

Comment: abbreviate first names to match with abbreviations in publication list
Category: Data Variable
Code:
stats_persons <- lapply(stats_persons, function(x){ x[2]<-str_sub(x[2], 1, 1) x }) stats_persons <- lapply(stats_persons, function(x)paste(x[1], x[2], sep = ","))
File: 6speciesismgraphs.R

Comment: Load the data
Category: Data Variable
Code:
load('../Relative Effectiveness Data - final.Rdata')
File: print_result.R

Comment: Print a txt and csv file with the results ' ' @param stats_to_print the tibble/table to print ' @param name_file name of the file to write ' ' @return 2 files with the results (txt and csv)
Category: Visualization
Code:
print_result <- function(stats_to_print, name_file){ knitr::kable( stats_to_print, format = "rst")  %>% cat( file = here('results', str_c(name_file, '.txt', sep = "")), sep = "\n") stats_to_print %>% write_csv(file = here('results', str_c(name_file, '.csv', sep = ""))) }
File: Study2_Load_Analysis_Post_Review_11-14-16_Final.R

Comment: convert degrees of freedom into numeric variables and store in new variable
Category: Data Variable
Code:
ScienceStatus$df.numerator.value = as.numeric(as.character(ScienceStatus$df.numerator)) ScienceStatus$df.denominator.value = as.numeric(as.character(ScienceStatus$df.denominator))

Comment: Assigning numeric values to variable labels which were stored in CSV
Category: Data Variable
Code:
ScienceStatus$coding.difficulty_r = revalue(ScienceStatus$coding.difficulty, c("Very Easy"="1", "Moderately Easy"="2", "Slightly Easy"="3", "Neither Difficult nor Easy"="4", "Slightly Difficult"="5", "Moderately Difficult"="6", "Very Difficult"="7")) ScienceStatus$coding.difficulty_r = as.numeric(as.character(ScienceStatus$coding.difficulty_r))

Comment: Calcuate EXACT pvalue from the stats reported in the paper (Posthoc)
Category: Statistical Test
Code:
ScienceStatus_J$Calc.Pvalue<-(rowSums(cbind(ScienceStatus_J$T.pvalue_calc, ScienceStatus_J$F.pvalue_calc, ScienceStatus_J$rg.pvalue_calc, ScienceStatus_J$r.pvalue_calc,ScienceStatus_J$chi.pvalue_calc), na.rm = TRUE) + ifelse(is.na(ScienceStatus_J$T.pvalue_calc) & is.na(ScienceStatus_J$F.pvalue_calc) & is.na(ScienceStatus_J$rg.pvalue_calc) & is.na(ScienceStatus_J$r.pvalue_calc) & is.na(ScienceStatus_J$chi.pvalue_calc), NA, 0))

Comment: PCurve Graph      Calculated from statistic and DF   By Paper
Category: Visualization
Code:
P.By.Paper<-ddply(ScienceStatus_SP, .(article.id,yearcat), summarize, Pmean.calc = stouffer.P(Calc.Pvalue.Clean), PMedian.calc = median(Calc.Pvalue.Clean))

Comment:     RIndex    Calcuate Mean, Median, Peak 
Category: Statistical Modeling
Code:
Rindex.Reults<-BCa.Boot.CI(ScienceStatus_SP,Calc.Z,r.index.calc.boot,LogT=FALSE,splitter=yearcat, StatType="AR") Rindex.Reults
File: Code_LMMs_Code_BestPractice_Example.R

Comment: FIGURE 3 Length in phonemes    RD  fit a model with fixed effects and with the random effect of subjects on intercepts and the slopes for length
Category: Statistical Modeling
Code:
Cue.Subj.lmer = glmer(ACC ~ CueCondition + zLengthPh + zFreq + (1+zLengthPh|Subject), data = NamingData, family = "binomial", control = glmerControl(optimizer="bobyqa")) summary(Cue.Subj.lmer)

Comment: extract fitted values and align with original data for plotting
Category: Visualization
Code:
a<-fitted.values(Cue.Subj.lmer) length(a) Dat<-na.omit(NamingData) #remove NAs from original data so aligns with model values Dat$fitted<-a names(Dat) a<-fitted.values(Cue.Subj.lmer) length(a) Dat<-na.omit(NamingData) #remove NAs from original data so aligns with model values Dat$fitted<-a names(Dat)

Comment: FIGURE 4a Plot average slope for effect of Frequency
Category: Visualization
Code:
p <- ggplot(data=Dat,aes(x=zFreq, y=fitted)) p <- p + geom_smooth(method = "glm") p <- p + xlab("Frequency (z score)") + ylab("Accuracy (model fit)") p <- p + ggtitle("4a) Average (group) effect of Frequency") p <- p + ylim(0,1) p <- p + theme_bw() + theme(text=element_text(size=12)) p
File: Kim Skalicky and Jung - R syntax.R

Comment: Main effects model for predicting inversion questions during alignment sessions.
Category: Statistical Modeling
Code:
inversion_main_effects_model<-glmer(inversion_dv ~ prime_type + WMC + modality +  inversion_production_pre + (1 + prime_type + trial_order | subject) + (1|verb), priming, family="binomial"(link="logit"),glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 100000))) summary(inversion_main_effects_model)

Comment: Odds ratios for main effects model
Category: Statistical Modeling
Code:
inversion.me.CI<-confint(inversion_main_effects_model, parm="beta_", level=0.90, method="Wald") inversion.me.tab <- cbind(est = fixef(inversion_main_effects_model),inversion.me.CI) inversion.me.tab <- exp(inversion.me.tab) inversion.me.tab <- as.data.frame(inversion.me.tab) inversion.me.tab <- rownames_to_column(inversion.me.tab) inversion.me.tab

Comment: Visualize the interaction between prime type and modality.  save the specific effect to a variable
Category: Visualization
Code:
effect2 <-effect("prime_type*modality",inversion_full_model_sig_int_only) summary(effect2) plot(effect2)

Comment: post hoc analyses to compare all levels of test order  between groups indirect production main effect only
Category: Statistical Test
Code:
ind_prod_me_between_groups <- emmeans(indirect_production_me,c("test_order"), type = "response") pairs(ind_prod_me_between_groups, reverse = F, type = 'response', adjust = 'none') plot(ind_prod_me_between_groups)
File: 9_manova_fda_socaccount.R

Comment: Test assumptions MANOVA  Test whether residuals are normally distributed
Category: Statistical Test
Code:
df$pc1.residuals = lm(pc1~condition.socaccount, data=df)$residuals df$pc2.residuals = lm(pc2~condition.socaccount, data=df)$residuals df$pc3.residuals = lm(pc3~condition.socaccount, data=df)$residuals df$pc4.residuals = lm(pc4~condition.socaccount, data=df)$residuals shapiro.test(df$pc1.residuals) shapiro.test(df$pc2.residuals) shapiro.test(df$pc3.residuals) shapiro.test(df$pc4.residuals)
File: anxiety_abstraction_s2.R

Comment: Only include tweets with at least 3 words
Category: Data Variable
Code:
final_twitter_data_ex <- final_twitter_data %>% filter(wc>=3) final_twitter_data_ex <- final_twitter_data_ex %>% filter(bryscore>=0.0001)

Comment: Means and SDs in feartweets and anxietytweets
Category: Data Variable
Code:
final_twitter_data_ex %>% group_by(fearVSanx) %>% summarise_at(vars(bryscore,i,we,they,focusfuture), list(mean=mean, sd=sd))

Comment: Independent samples ttest: Brysbaert concreteness score as DV
Category: Statistical Test
Code:
t.test_bci <- final_twitter_data_ex %>% rstatix::t_test(bryscore ~ fearVSanx, var.equal = TRUE, detailed=TRUE) %>% rstatix::add_significance() t.test_bci
File: load_all_tables.R

Comment: convert age from months to years
Category: Data Variable
Code:
demog.tab$interview_age <- demog.tab$interview_age / 12
File: make_fig1_main_text.R

Comment: multinomial CI (these are simulataneous CI although assume full pooling)
Category: Statistical Modeling
Code:
obs_p_CI <- DescTools::MultinomCI(pl_d$N, conf.level=1-0.05/2, method="goodman") *4 pl_d$obs_p_lb <- obs_p_CI[,2] pl_d$obs_p_ub <- obs_p_CI[,3] pl_d %>% mutate(resp_true = ifelse(k>=4,1,0), fill_group = str_c(item, resp_true, type), line_group = str_c(item, type), item = factor(item, levels=c("true","false"))) %>% ggplot(aes(x=k,y=obs_p))+ facet_grid(item ~ type) + nice_theme + geom_col(aes(fill=fill_group))+ geom_errorbar(aes(y=obs_p,ymin=obs_p_lb, ymax=obs_p_ub),color="dark grey",width=0,lwd=0.8)+

Comment: Mratio posterior density plot
Category: Visualization
Code:
log_mu_sci <- unlist(c(output[,grep('mu_logMratio_1',varnames(output))])) log_mu_cov <- unlist(c(output[,grep('mu_logMratio_2',varnames(output))])) d_groupM <- data.frame(logM =c(log_mu_sci,log_mu_cov), type=c(rep('science',length(log_mu_sci)),rep('Covid-19',length(log_mu_sci)))) d_groupM %>% mutate(M=exp(logM)) %>% ggplot(aes(x=M,y=type,fill=type))+ nice_theme + geom_vline(xintercept = 1, lty=2,size=0.4)+ stat_halfeye(.width = c(.95, .95),aes(fill=type),alpha=0.8)+
File: facebook_users.R

Comment: Convert `campaign_week` from a character string to a factor with 11 levels to order weeks chronologically.
Category: Data Variable
Code:
Facebook_Users$campaign_week <- factor(Facebook_Users$campaign_week, levels = c("Week 1", "Week 2", "Week 3", "Week 4", "Week 5", "Week 6", "Week 7", "Week 8", "Week 9", "Week 10", "Week 11", "Election Day"))

Comment: Convert `candidate_page` from a character string to a factor with 3 levels.(Facilitates data visualization and data exploration).
Category: Visualization
Code:
Facebook_Users$candidate_page <- factor(Facebook_Users$candidate_page, levels = c ("Harper", "Trudeau", "Mulcair"))

Comment: Adds a new column to identify the Facebook page being `liked`.
Category: Data Variable
Code:
Harper_User_Likes$partisanship <- "Conservative" Trudeau_User_Likes$partisanship <- "Liberal" Mulcair_User_Likes$partisanship <- "Social Democrat"

Comment: Match partisan assignment from Facebook_User_Likes to the Facebook Users Dataset using `user_id`.
Category: Data Variable
Code:
Facebook_Users$partisanship <- NA Facebook_Users$partisanship <- Facebook_User_Likes$partisanship[match(Facebook_Users$user_id, Facebook_User_Likes$user_id)]

Comment: Convert `partisanship` from a character string to a factor with 3 levels.(Facilitates data visualization and data exploration).
Category: Data Variable
Code:
Facebook_Users$partisanship <- factor(Facebook_Users$partisanship, levels = c ("Conservative", "Liberal", "Social Democrat"))
File: IMDB_analysis.r

Comment: split the data and transform it into integers
Category: Data Variable
Code:
ARTE <- as.numeric(data[which(data$TV.Station == 'ARTE'),]$Rating) Degeto <- as.numeric(data[which(data$TV.Station == 'Degeto Film'),]$Rating)

Comment: run the onesided ttest with alpha  0.1
Category: Statistical Test
Code:
t.test(ARTE, Degeto, alternative = "greater", conf.level = 0.90)