Commit 960011ce authored by Maike Kleemeyer's avatar Maike Kleemeyer
Browse files

check-in files

parent 7128b48c
.Rproj.user
.Rhistory
.RData
.Ruserdata
# COMPUTE sum scores and means for A2, A3, B1, B2, C1, D1, D2, E1, E2, G1, G5, G7
# Run Factor analysis on all likert scale items
## OLD R CODE
setwd("~/Seafile/FragebogenMpg")
file1 = read.csv("20200106_MPG Work Culture_Basic Data_likert.csv",header=TRUE,sep=";")
library(psych)
library(umx)
library(ggplot2)
library(Hmisc)
file1$H1_gender <- as.factor(file1$H1_gender)
scale_a <- subset(file1, select = A2_groupatmo1_1:A3_groupatmo4_3)
umxEFA(file1, factors = 19, scores= "ML")
print(class(file1[[i]]))
for (i in colnames(file1)){
p <- ggplot(file1, aes(x=c("all"),
y=file1[[i]]))
+ geom_violin(trim=FALSE)
data_summary <- function(x) {
m <- mean(x)
ymin <- m-sd(x)
ymax <- max(x)
return(c(y=m,ymin=ymin,ymax=ymax))
}
p + stat_summary(fun.data=data_summary)
p <- ggplot(file1, aes(x=file1$H1_gender,
y=file1[[i]], fill=file1$H1_gender))
+ geom_violin(trim=FALSE)
data_summary <- function(x) {
m <- mean(x)
ymin <- m-sd(x)
ymax <- max(x)
return(c(y=m,ymin=ymin,ymax=ymax))
}
p + stat_summary(fun.data=data_summary)
p <- ggplot(file1, aes(x=file1$H1_gender,
y=file1[[i]], fill=file1$startlanguage))
+ geom_violin(trim=FALSE)
data_summary <- function(x) {
m <- mean(x)
ymin <- m-sd(x)
ymax <- max(x)
return(c(y=m,ymin=ymin,ymax=ymax))
}
p + stat_summary(fun.data=data_summary)
}
library(limer)
library(tidyverse)
library(rio) # if using import
# OR IF NOT POSSIBLE OTHERWISE
responses <- import("/Users/kleemeyer/Seafile/FragebogenMpg/generalscript_Dec2020/Mitarbeitenden_Umfrage_Standardexport_Code.xlsx")
# recode data from text answers to numerical data we can work with
# QUESTION: How do we code "KEINE ANTWORT"?? As opposed to no answer provided and not applicable )because never happened)?
# RECODING of I Question??
responses_coded <- responses %>%
select_if(~!is.logical(.)) %>%
mutate_all(na_if,"") %>%
mutate(across(A01:`D20[SQ007]`, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(E01 = recode(E01, "Die Karrieren von Frauen werden weniger gefördert als die von Männern" = 1, "Die Karrieren von Frauen und Männern werden gleichermaßen gefördert" = 0, "Die Karrieren von Frauen werden stärker gefördert als die von Männern" = -1, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)) %>%
mutate(across(E03:`F19[SQ007]`, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(`G01[SQ001]`:`G04[SQ002]`, ~recode(., "Ist mir bereits bekannt." = 1, "Ist mir nicht bekannt." = 2, "Keine Antwort." = NA_real_, "Keine Antwort" = NA_real_, "N/A" = NA_real_))) %>%
mutate(across(H02:H14, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(H17:H21, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)))
library(limer)
library(tidyverse)
# HERE WE SET UP THE REPECTIVE SURVEY OPTIONS, SO THIS SHOULD BE CHANGED!!!
options(lime_api = 'https://survey3.gwdg.de/index.php?r=admin/remotecontrol')
options(lime_username = 'maike.kleemeyer')
options(lime_password = 'Zfznye5XUJWQ')
get_session_key()
# include the survey ID (to be found on the LimeSurvey page) here
responses <- get_responses(944399)
# recode data from text answers to numerical data we can work with
# QUESTION: How do we code "KEINE ANTWORT"?? As opposed to no answer provided and not applicable )because never happened)?
# RECODING of I Question??
responses_de <- responses %>%
filter(startlanguage=="de") %>%
select_if(~!is.logical(.)) %>%
mutate_all(na_if,"") %>%
mutate(across(A01:D20.SQ007., ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(E01 = recode(E01, "Die Karrieren von Frauen werden weniger gefördert als die von Männern" = 1, "Die Karrieren von Frauen und Männern werden gleichermaßen gefördert" = 0, "Die Karrieren von Frauen werden stärker gefördert als die von Männern" = -1, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)) %>%
mutate(across(E03:F19.SQ007., ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(G01.SQ001.:G04.SQ002., ~recode(., "Ist mir bereits bekannt." = 1, "Ist mir nicht bekannt." = 2, "Keine Antwort." = NA_real_, "N/A" = NA_real_))) %>%
mutate(across(H02:H14, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(H17:H21, ~recode(., "Ja" = 1, "Stimme überhaupt nicht zu" = 1, "Nie" = 1, "Nein" = 2, "Stimme nicht zu" = 2, "Gelegentlich" = 2, "Weder noch" = 3, "Monatlich" = 3, "Stimme zu" = 4, "Wöchentlich" = 4, "Stimme voll und ganz zu" = 5, "Täglich" = 5, "Keine Antwort" = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)))
responses_en <- responses %>%
filter(startlanguage=="en") %>%
select_if(~!is.logical(.)) %>%
mutate_all(na_if,"") %>%
mutate(across(A01:D20.SQ007., ~recode(., "Yes" = 1, "Strongly disagree" = 1, "Never" = 1, "No" = 2, "Disagree" = 2, "Occasionally" = 2, "Neither agree nor disagree" = 3, "Monthly" = 3, "Agree" = 4, "Weekly" = 4, "Strongly agree" = 5, "Daily" = 5, "No answer " = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(E01 = recode(E01, "The careers of women are promoted less than those of men" = 1, "The careers of women and men are promoted equally" = 0, "The careers of women are promoted more than those of men" = -1, "No answer " = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)) %>%
mutate(across(E03:F19.SQ007., ~recode(., "Yes" = 1, "Strongly disagree" = 1, "Never" = 1, "No" = 2, "Disagree" = 2, "Occasionally" = 2, "Neither agree nor disagree" = 3, "Monthly" = 3, "Agree" = 4, "Weekly" = 4, "Strongly agree" = 5, "Daily" = 5, "No answer " = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(G01.SQ001.:G04.SQ002., ~recode(., "I am aware of this possibility" = 1, "I am not aware of this possibility" = 2, "No Answer" = NA_real_, "N/A" = NA_real_))) %>%
mutate(across(H02:H14, ~recode(., "Yes" = 1, "Strongly disagree" = 1, "Never" = 1, "No" = 2, "Disagree" = 2, "Occasionally" = 2, "Neither agree nor disagree" = 3, "Monthly" = 3, "Agree" = 4, "Weekly" = 4, "Strongly agree" = 5, "Daily" = 5, "No answer " = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999))) %>%
mutate(across(H17:H21, ~recode(., "Yes" = 1, "Strongly disagree" = 1, "Never" = 1, "No" = 2, "Disagree" = 2, "Occasionally" = 2, "Neither agree nor disagree" = 3, "Monthly" = 3, "Agree" = 4, "Weekly" = 4, "Strongly agree" = 5, "Daily" = 5, "No answer " = NA_real_, "N/A" = NA_real_, .missing = NA_real_, .default = 999)))
responses_coded <- bind_rows(responses_de,responses_en)
release_session_key()
\ No newline at end of file
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment