This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
set.seed(123) | |
# Problem: I want to plot the responses to certain items | |
# by each condition (a response on other ) | |
# lets simulate some data. | |
# here we have two conditions, 10 items and 5 response options | |
n = 6000 | |
df <- data.frame( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("tidyverse", "ggpubr", "see") | |
set.seed(123) | |
n = 100 | |
df = data.frame( | |
part = paste0("id", 1:n), | |
scale_A = rnorm(n, m = 10, sd = 5), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imagine that you want to plot the responses of a ordinal questionnaire | |
# besides the common practice, is not always correct to use ordinal data as | |
# continous. There are good resources like https://bookdown.org/Rmadillo/likert/always-visualize.html | |
# which tell you how to proper represent ordinal data. However, I found that if your scale has missing | |
# response options in one question... the package likert does not deal with that | |
# so, I self-made the plot(ex_2_likert, type = "heat") graph | |
# Creating a fake "ordinal" data with seven questions with 0-4 responses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sometimes, you will find useful to discretize a variable. | |
# An option to do that is creating three equal sized groups | |
# this is, trichotomization. | |
# Reference http://www.stat.columbia.edu/~gelman/research/published/thirds5.pdf | |
library(Hmisc) | |
# We use cut2 to create three equal groups | |
# then, by taking the number with as.numeric | |
# we will have a column filled with the group membership |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cond_1 | cond_2 | measure_1 | measure_2 | measure_3 | ||
---|---|---|---|---|---|---|
316 | 1 | 0 | 26 | 20 | 34 | |
476 | 0 | 0 | 14 | 10 | 12 | |
339 | 1 | 1 | 21 | 6 | 16 | |
271 | 0 | 0 | 15 | 8 | 25 | |
541 | 0 | 1 | 20 | 14 | 24 | |
376 | 1 | 1 | 26 | 15 | 30 | |
147 | 0 | 1 | 26 | 24 | 22 | |
471 | 1 | 0 | 14 | 7 | 23 | |
328 | 0 | 0 | 19 | 10 | 20 |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id;edad;LETRA FAVORITA;humor;calida de su letra ñ | |
A1;21;a;bueno;1 | |
A2;22;B;bueno;2 | |
A3;333;C;bueno;3 | |
A4;89;D;bueno;4 | |
A5;90;c;malo;5 | |
A6;45;d;malo;6 | |
A7;65;c;malo;7 | |
A8;34;a;malo;8 | |
A9;23;b;malo;9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################### | |
# Cluster Analysis de la valoración | |
###################################################################### | |
rm(list=ls()); gc() | |
options(scipen=20) | |
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("tidyverse", "psych", "haven", "reshape2", "qgraph", "Rmisc", "Hmisc", "mclust", "corrplot") | |
# Sacamos del CIS la encuesta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creados para tuitear sobre la encuesta preelectoral y hacer este tuit https://twitter.com/GuidoBCor/status/1120248040848334849 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("ggplot2", "Rmisc") | |
############################################################# | |
# Preparing data (you can skip this and go to the plot : ) | |
############################################################# | |
# Simulate some date by trial | |
parts = 30 # Our participants | |
trials = 60 # Our Trials | |
df=data.frame() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################# | |
## Estimating and plotting Generalized Linear Mixed Models ## | |
############################################################# | |
# This script will | |
# 1) Simulate some experimental data | |
# 2) Run a glmer with afex | |
# 3) Estimate predicted marginal means with emmeans | |
# 4) Plot estimates |
NewerOlder