## global variables
= FALSE save_CAMs_as_pictures
Split CAMs, get tidy data
Notes
Remark:
prepare raw data
load packages, raw data, functions
# sets the directory of location of this script as the current directory
# setwd(dirname(rstudioapi::getSourceEditorContext()$path))
########################################
# load packages
########################################
require(pacman)
p_load('tidyverse', 'jsonlite', 'magrittr', 'xlsx',
'stargazer', 'psych', 'jtools', 'DT', 'ggstatsplot',
'lavaan',
'regsem', 'MplusAutomation', 'igraph',
'vroom')
########################################
# load data files
########################################
setwd("data")
dir()
### load CAM file
suppressMessages(read_file("CAMs(N=28).txt") %>%
# ... split it into lines ...
str_split('\n') %>% first() %>%
discard(function(x) x == '') %>%
discard(function(x) x == '\r') %>%
# ... filter empty rows ...
discard(function(x) x == '')) -> dat_CAM
<- list()
raw_CAM for(i in 1:length(dat_CAM)){
<- jsonlite::fromJSON(txt = dat_CAM[[i]])
raw_CAM[[i]]
}# rm(dat_CAM)
## load file for manually overwriting words
<- read.delim(file="rdata_openspace-CAM_2024-05-07_15-53.csv", encoding="UTF-8", fileEncoding="UTF-8",
dat_SosciSurvey header = FALSE, sep = "\t", quote = "\"",
dec = ".", row.names = NULL,
col.names = c(
"CASE","SERIAL","REF","QUESTNNR","MODE","STARTED","BD05_01","BD01_01","BD02",
"BD06","BD07","BD08_01","BD09_01","BD09_02","TE01_RV1","TE02","TE02_02",
"TIME001","TIME002","TIME003","TIME004","TIME005","TIME006","TIME007","TIME008",
"TIME009","TIME010","TIME011","TIME012","TIME013","TIME014","TIME015","TIME016",
"TIME017","TIME018","TIME019","TIME020","TIME021","TIME022","TIME023","TIME024",
"TIME025","TIME026","TIME027","TIME028","TIME029","TIME030","TIME031",
"TIME_SUM","MAILSENT","LASTDATA","FINISHED","Q_VIEWER","LASTPAGE","MAXPAGE",
"MISSING","MISSREL","TIME_RSI"
),as.is = TRUE,
colClasses = c(
CASE="numeric", SERIAL="character", REF="character", QUESTNNR="character",
MODE="factor", STARTED="POSIXct", BD05_01="character", BD01_01="numeric",
BD02="numeric", BD06="numeric", BD07="numeric", BD08_01="character",
BD09_01="character", BD09_02="character", TE01_RV1="character",
TE02="numeric", TE02_02="character", TIME001="integer", TIME002="integer",
TIME003="integer", TIME004="integer", TIME005="integer", TIME006="integer",
TIME007="integer", TIME008="integer", TIME009="integer", TIME010="integer",
TIME011="integer", TIME012="integer", TIME013="integer", TIME014="integer",
TIME015="integer", TIME016="integer", TIME017="integer", TIME018="integer",
TIME019="integer", TIME020="integer", TIME021="integer", TIME022="integer",
TIME023="integer", TIME024="integer", TIME025="integer", TIME026="integer",
TIME027="integer", TIME028="integer", TIME029="integer", TIME030="integer",
TIME031="integer", TIME_SUM="integer", MAILSENT="POSIXct",
LASTDATA="POSIXct", FINISHED="logical", Q_VIEWER="logical",
LASTPAGE="numeric", MAXPAGE="numeric", MISSING="numeric", MISSREL="numeric",
TIME_RSI="numeric"
),skip = 1,
check.names = TRUE, fill = TRUE,
strip.white = FALSE, blank.lines.skip = TRUE,
comment.char = "",
na.strings = ""
)
########################################
# load functions
########################################
# print(getwd())
setwd("../functions")
for(i in 1:length(dir())){
# print(dir()[i])
source(dir()[i], encoding = "utf-8")
}
setwd("../functions_CAMapp")
for(i in 1:length(dir())){
# print(dir()[i])
source(dir()[i], encoding = "utf-8")
}rm(i)
set up CAM data
ceck for CAM ids
not all CAMs have unique IDs!!!
<- c()
vec_ids for(i in 1:length(raw_CAM)){
<- raw_CAM[[i]]$creator
vec_ids[i]
if(raw_CAM[[i]]$creator == "032"){
print(i)
} }
[1] 5
[1] 8
length(unique(vec_ids))
[1] 28
table(vec_ids)
vec_ids
001 002 003 005 006 007 008 009 010 011 012 013 014 015 017 018 019 020 021 022
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
024 025 026 028 029 030 031 032
1 1 1 1 1 1 1 2
length(raw_CAM)
[1] 29
8]]$creator <- "032_2" raw_CAM[[
set up CAM data
Create CAM files, draw CAMs and compute network indicators
### create CAM single files (nodes, connectors, merged)
<- create_CAMfiles(datCAM = raw_CAM, reDeleted = TRUE) CAMfiles
Nodes and connectors, which were deleted by participants were removed.
# deleted nodes: 138
# deleted connectors: 30
## remove empty concepts:
1]]$text[nchar(CAMfiles[[1]]$text) < 2] CAMfiles[[
[1] "" ""
<- CAMfiles[[1]]$id[nchar(CAMfiles[[1]]$text) < 2]
tmp_ids table(CAMfiles[[1]]$isActive[CAMfiles[[1]]$id %in% tmp_ids])
TRUE
2
1]] <- CAMfiles[[1]][!CAMfiles[[1]]$id %in% tmp_ids,]
CAMfiles[[
### apply protocol
setwd("data")
<- readLines("protocol_v01.txt", warn = FALSE)
text <- readLines(textConnection(text, encoding = "UTF-8"), encoding = "UTF-8")
text
if (testIfJson(file = text)) {
<-
protocol ::fromJSON(file = "protocol_v01.txt")
rjson
## no CAM deleted
print(protocol$deletedCAMs)
<- overwriteTextNodes(protocolDat = protocol,
tmp_out nodesDat = CAMfiles[[1]])
1]] <- tmp_out[[1]]
CAMfiles[[# tmp_out[[2]]
else{
} print("Invalid protocol uploaded")
}
[1] "0a8e44bb-027d-4b3b-8b27-934860eb33e3"
time 2024-03-27 09:09:45.468222 at index 1 for approximate matching
time 2024-03-27 09:09:54.375455 at index 2 for approximate matching
time 2024-03-27 09:10:00.055962 at index 3 for approximate matching
time 2024-03-27 09:10:16.361624 at index 4 for approximate matching
time 2024-03-27 09:10:20.03996 at index 5 for approximate matching
time 2024-03-27 09:10:31.792348 at index 6 for approximate matching
time 2024-03-27 09:10:39.742539 at index 7 for approximate matching
time 2024-03-27 09:10:57.011727 at index 8 for approximate matching
time 2024-03-27 09:11:09.777395 at index 9 for approximate matching
time 2024-03-27 09:11:14.326505 at index 10 for approximate matching
time 2024-03-27 09:11:19.877418 at index 11 for approximate matching
time 2024-03-27 09:11:21.025896 at index 12 for approximate matching
time 2024-03-27 09:11:32.345376 at index 13 for approximate matching
time 2024-03-27 09:11:35.527045 at index 14 for approximate matching
time 2024-03-27 09:11:59.676772 at index 15 for approximate matching
time 2024-03-27 09:12:06.558638 at index 16 for approximate matching
time 2024-03-27 09:12:11.426233 at index 17 for approximate matching
time 2024-03-27 09:12:18.259098 at index 18 for approximate matching
time 2024-03-27 09:12:26.172405 at index 19 for approximate matching
time 2024-03-27 09:12:46.243045 at index 20 for approximate matching
time 2024-03-27 09:12:58.95868 at index 21 for approximate matching
time 2024-03-27 09:13:01.860362 at index 22 for approximate matching
time 2024-03-27 09:13:08.225296 at index 23 for approximate matching
time 2024-03-27 09:13:34.377537 at index 24 for approximate matching
time 2024-03-27 09:13:39.706119 at index 25 for approximate matching
time 2024-03-27 09:13:50.87323 at index 26 for approximate matching
time 2024-03-27 09:14:01.790417 at index 27 for approximate matching
time 2024-03-27 09:14:13.457764 at index 28 for approximate matching
time 2024-03-27 09:14:32.022188 at index 29 for approximate matching
time 2024-03-27 09:14:37.090642 at index 30 for approximate matching
time 2024-03-27 09:15:00.40541 at index 31 for approximate matching
time 2024-03-27 09:15:50.8418 at index 32 for approximate matching
time 2024-03-27 09:16:03.553642 at index 33 for approximate matching
time 2024-03-27 09:16:51.192392 at index 34 for approximate matching
time 2024-03-27 09:17:14.723674 at index 35 for approximate matching
time 2024-03-27 09:17:20.37401 at index 36 for approximate matching
time 2024-03-27 09:17:36.056367 at index 37 for approximate matching
time 2024-03-27 09:18:00.589159 at index 38 for approximate matching
time 2024-03-27 09:18:22.040034 at index 39 for approximate matching
time 2024-03-27 09:18:28.17327 at index 40 for approximate matching
time 2024-03-27 09:19:39.768021 at index 41 for approximate matching
time 2024-03-27 09:19:46.603037 at index 42 for approximate matching
time 2024-03-27 09:20:04.486784 at index 43 for approximate matching
time 2024-03-27 09:20:15.918261 at index 44 for approximate matching
time 2024-03-27 09:20:28.343038 at index 45 for approximate matching
time 2024-03-27 09:20:34.385201 at index 46 for approximate matching
time 2024-03-27 09:22:27.156596 at index 47 for search terms
time 2024-03-27 09:23:40.88302 at index 48 for search terms
time 2024-03-27 09:26:02.514854 at index 49 for search terms
time 2024-03-27 09:27:28.79977 at index 50 for search terms
time 2024-03-27 09:28:24.113472 at index 51 for search terms
time 2024-03-27 09:31:02.480129 at index 52 for search terms
time 2024-03-27 09:32:21.027863 at index 53 for search terms
time 2024-03-27 09:33:50.364135 at index 54 for search terms
time 2024-03-27 09:35:53.259618 at index 55 for search terms
time 2024-03-27 09:38:59.688684 at index 56 for search terms
time 2024-03-27 09:41:31.539652 at index 57 for search terms
time 2024-03-27 09:44:08.538553 at index 58 for search terms
time 2024-03-27 09:44:39.619148 at index 59 for search terms
time 2024-03-27 09:45:13.460504 at index 60 for search terms
time 2024-03-27 09:49:27.390569 at index 61 for search terms
time 2024-03-27 09:50:02.809324 at index 62 for search terms
time 2024-03-27 09:50:31.324591 at index 63 for search terms
time 2024-03-27 09:51:16.39256 at index 64 for search terms
time 2024-03-27 09:54:59.443253 at index 65 for search terms
time 2024-03-27 09:58:00.931791 at index 66 for search terms
time 2024-03-27 09:58:31.5607 at index 67 for search terms
time 2024-03-27 09:59:24.044396 at index 68 for search terms
time 2024-03-27 10:00:18.76173 at index 69 for search terms
time 2024-03-27 10:01:07.70914 at index 70 for search terms
time 2024-03-27 10:01:58.763652 at index 71 for search terms
time 2024-03-27 10:03:12.667148 at index 72 for search terms
time 2024-03-27 10:05:50.349782 at index 73 for search terms
time 2024-03-27 10:07:57.996942 at index 74 for search terms
time 2024-03-27 10:08:57.895383 at index 75 for search terms
time 2024-03-27 10:10:52.07574 at index 76 for search terms
time 2024-03-27 10:11:38.249778 at index 77 for search terms
time 2024-03-27 10:15:13.535888 at index 78 for search terms
time 2024-03-27 10:16:53.302933 at index 79 for search terms
time 2024-03-27 10:18:33.287615 at index 80 for search terms
### draw CAMs
<- draw_CAM(dat_merged = CAMfiles[[3]],
CAMdrawn dat_nodes = CAMfiles[[1]],ids_CAMs = "all",
plot_CAM = FALSE,
useCoordinates = TRUE,
relvertexsize = 3,
reledgesize = 1)
processing 29 CAMs...
Warning: `graph.data.frame()` was deprecated in igraph 2.0.0.
ℹ Please use `graph_from_data_frame()` instead.
[1] "== participantCAM in drawnCAM"
## check for non reasonable words
for(i in 1:length(CAMdrawn)){
if(any(nchar(V(CAMdrawn[[i]])$label) < 3)){
print(V(CAMdrawn[[i]])$label)
} }
[1] "damalige Erwartungen ans neue Büro" "aktuelles Erleben im neuen Büro"
[3] "Viel leichtere Kommunikation" "Mein Sitzplatz"
[5] "Viel Kontakt " "freie Platzwahl_positive"
[7] "Rückzugsmöglichkeiten_positive" "Ablenkung_negative"
[9] "schnellere Kommunikation_positive" "Privatsphäre_negative"
[11] "Geräuschpegel_negative" "Nein"
[13] "Ja" "Keine Privatsphäre "
[15] "Schnelle Gespräche" "Informationsaustausch_positive"
### network indicators
<- c("aktuelles Erleben im neuen Büro", "damalige Erwartungen ans neue Büro") # pre-defined concepts
tmp_microIndicator <- compute_indicatorsCAM(drawn_CAM = CAMdrawn,
networkIndicators micro_degree = tmp_microIndicator,
micro_valence = tmp_microIndicator,
micro_centr_clo = tmp_microIndicator,
micro_transitivity = tmp_microIndicator,
largestClique = FALSE)
Warning: `graph.density()` was deprecated in igraph 2.0.0.
ℹ Please use `edge_density()` instead.
Warning: The `types1` argument of `assortativity()` is deprecated as of igraph 1.6.0.
ℹ Please use the `values` argument instead.
Warning: `assortativity.degree()` was deprecated in igraph 2.0.0.
ℹ Please use `assortativity_degree()` instead.
<- compute_neighborhoodIndicatorsCAM(drawn_CAM = CAMdrawn,
neighborhood_networkIndicators weightSecondOrder = .5,
consideredConcepts = tmp_microIndicator,
sliceCAMbool = TRUE,
removeConnectionCAM = tmp_microIndicator,
removeNodeCAM = NULL)
Warning: `are.connected()` was deprecated in igraph 2.0.0.
ℹ Please use `are_adjacent()` instead.
## check for CAMs who have not changed valence
<- networkIndicators$CAM_ID[is.na(networkIndicators$assortativity_valence_macro)]
tmp_ids for(i in tmp_ids){
plot(CAMdrawn[[i]], edge.arrow.size = .7,
layout=layout_nicely, vertex.frame.color="black", asp = .5, margin = -0.1,
vertex.size = 10, vertex.label.cex = .9)
}
### wordlist
<- create_wordlist(
CAMwordlist dat_nodes = CAMfiles[[1]],
dat_merged = CAMfiles[[3]],
useSummarized = TRUE,
order = "frequency",
splitByValence = FALSE,
comments = TRUE,
raterSubsetWords = NULL,
rater = FALSE
)
[1] "create_wordlist - use summarized words"
[1] 198
[1] 512
[1] "temporarily suffixes are added, because not all words have been summarized"
processing 29 CAMs...
[1] "== participantCAM in drawnCAM"
::datatable(CAMwordlist, options = list(pageLength = 5)) DT
correlation plot network indicators
cor.plot(r = cor(neighborhood_networkIndicators[, str_subset(string = colnames(neighborhood_networkIndicators), pattern = "aktuellesErlebenimneuenBüro")],
use = "pairwise"), xlas = 1, upper = FALSE, cex = .8)
cor.plot(r = cor(neighborhood_networkIndicators[, str_subset(string = colnames(neighborhood_networkIndicators), pattern = "damaligeErwartungenansneueBüro")],
use = "pairwise"), xlas = 1, upper = FALSE, cex = .8)
set up Sosci Survey data
prepare data
row.names(dat_SosciSurvey) = dat_SosciSurvey$CASE
attr(dat_SosciSurvey, "project") = "openspace-CAM"
attr(dat_SosciSurvey, "description") = "Open Space"
attr(dat_SosciSurvey, "date") = "2024-05-07 15:53:35"
attr(dat_SosciSurvey, "server") = "https://www.soscisurvey.de"
# Variable und Value Labels
$BD02 = factor(dat_SosciSurvey$BD02, levels=c("1","2","3","4","5","-9"), labels=c("Weiblich","Männlich","divers","<4>","Das möchte ich nicht angeben","[NA] nicht beantwortet"), ordered=FALSE)
dat_SosciSurvey$BD06 = factor(dat_SosciSurvey$BD06, levels=c("1","2","-9"), labels=c("ja","nein","[NA] nicht beantwortet"), ordered=FALSE)
dat_SosciSurvey$BD07 = factor(dat_SosciSurvey$BD07, levels=c("1","2","-9"), labels=c("ja","nein","[NA] nicht beantwortet"), ordered=FALSE)
dat_SosciSurvey$TE02 = factor(dat_SosciSurvey$TE02, levels=c("1","2","-9"), labels=c("Nein","Ja, und zwar","[NA] nicht beantwortet"), ordered=FALSE)
dat_SosciSurveyattr(dat_SosciSurvey$FINISHED,"F") = "abgebrochen"
attr(dat_SosciSurvey$FINISHED,"T") = "ausgefüllt"
attr(dat_SosciSurvey$Q_VIEWER,"F") = "Teilnehmer"
attr(dat_SosciSurvey$Q_VIEWER,"T") = "Durchklicker"
comment(dat_SosciSurvey$SERIAL) = "Personenkennung oder Teilnahmecode (sofern verwendet)"
comment(dat_SosciSurvey$REF) = "Referenz (sofern im Link angegeben)"
comment(dat_SosciSurvey$QUESTNNR) = "Fragebogen, der im Interview verwendet wurde"
comment(dat_SosciSurvey$MODE) = "Interview-Modus"
comment(dat_SosciSurvey$STARTED) = "Zeitpunkt zu dem das Interview begonnen hat (Europe/Berlin)"
comment(dat_SosciSurvey$BD05_01) = "ID: [01]"
comment(dat_SosciSurvey$BD01_01) = "Alter: ... Jahre"
comment(dat_SosciSurvey$BD02) = "Geschlecht"
comment(dat_SosciSurvey$BD06) = "readiness for change"
comment(dat_SosciSurvey$BD07) = "Partizipation"
comment(dat_SosciSurvey$BD08_01) = "Tage im Büro: [01]"
comment(dat_SosciSurvey$BD09_01) = "Jahre im Unternehmen: ... Jahre"
comment(dat_SosciSurvey$BD09_02) = "Jahre im Unternehmen: und ... Monate"
comment(dat_SosciSurvey$TE01_RV1) = "POST/GET-Variable: participantID"
comment(dat_SosciSurvey$TE02) = "Technische Probleme?"
comment(dat_SosciSurvey$TE02_02) = "Technische Probleme?: Ja, und zwar"
comment(dat_SosciSurvey$TIME001) = "Verweildauer Seite 1"
comment(dat_SosciSurvey$TIME002) = "Verweildauer Seite 2"
comment(dat_SosciSurvey$TIME003) = "Verweildauer Seite 3"
comment(dat_SosciSurvey$TIME004) = "Verweildauer Seite 4"
comment(dat_SosciSurvey$TIME005) = "Verweildauer Seite 5"
comment(dat_SosciSurvey$TIME006) = "Verweildauer Seite 6"
comment(dat_SosciSurvey$TIME007) = "Verweildauer Seite 7"
comment(dat_SosciSurvey$TIME008) = "Verweildauer Seite 8"
comment(dat_SosciSurvey$TIME009) = "Verweildauer Seite 9"
comment(dat_SosciSurvey$TIME010) = "Verweildauer Seite 10"
comment(dat_SosciSurvey$TIME011) = "Verweildauer Seite 11"
comment(dat_SosciSurvey$TIME012) = "Verweildauer Seite 12"
comment(dat_SosciSurvey$TIME013) = "Verweildauer Seite 13"
comment(dat_SosciSurvey$TIME014) = "Verweildauer Seite 14"
comment(dat_SosciSurvey$TIME015) = "Verweildauer Seite 15"
comment(dat_SosciSurvey$TIME016) = "Verweildauer Seite 16"
comment(dat_SosciSurvey$TIME017) = "Verweildauer Seite 17"
comment(dat_SosciSurvey$TIME018) = "Verweildauer Seite 18"
comment(dat_SosciSurvey$TIME019) = "Verweildauer Seite 19"
comment(dat_SosciSurvey$TIME020) = "Verweildauer Seite 20"
comment(dat_SosciSurvey$TIME021) = "Verweildauer Seite 21"
comment(dat_SosciSurvey$TIME022) = "Verweildauer Seite 22"
comment(dat_SosciSurvey$TIME023) = "Verweildauer Seite 23"
comment(dat_SosciSurvey$TIME024) = "Verweildauer Seite 24"
comment(dat_SosciSurvey$TIME025) = "Verweildauer Seite 25"
comment(dat_SosciSurvey$TIME026) = "Verweildauer Seite 26"
comment(dat_SosciSurvey$TIME027) = "Verweildauer Seite 27"
comment(dat_SosciSurvey$TIME028) = "Verweildauer Seite 28"
comment(dat_SosciSurvey$TIME029) = "Verweildauer Seite 29"
comment(dat_SosciSurvey$TIME030) = "Verweildauer Seite 30"
comment(dat_SosciSurvey$TIME031) = "Verweildauer Seite 31"
comment(dat_SosciSurvey$TIME_SUM) = "Verweildauer gesamt (ohne Ausreißer)"
comment(dat_SosciSurvey$MAILSENT) = "Versandzeitpunkt der Einladungsmail (nur für nicht-anonyme Adressaten)"
comment(dat_SosciSurvey$LASTDATA) = "Zeitpunkt als der Datensatz das letzte mal geändert wurde"
comment(dat_SosciSurvey$FINISHED) = "Wurde die Befragung abgeschlossen (letzte Seite erreicht)?"
comment(dat_SosciSurvey$Q_VIEWER) = "Hat der Teilnehmer den Fragebogen nur angesehen, ohne die Pflichtfragen zu beantworten?"
comment(dat_SosciSurvey$LASTPAGE) = "Seite, die der Teilnehmer zuletzt bearbeitet hat"
comment(dat_SosciSurvey$MAXPAGE) = "Letzte Seite, die im Fragebogen bearbeitet wurde"
comment(dat_SosciSurvey$MISSING) = "Anteil fehlender Antworten in Prozent"
comment(dat_SosciSurvey$MISSREL) = "Anteil fehlender Antworten (gewichtet nach Relevanz)"
comment(dat_SosciSurvey$TIME_RSI) = "Ausfüll-Geschwindigkeit (relativ)"
# Assure that the comments are retained in subsets
= as.data.frame.vector
as.data.frame.avector `[.avector` <- function(x,i,...) {
<- NextMethod("[")
r mostattributes(r) <- attributes(x)
r
}= data.frame(
dat_SosciSurvey_tmp lapply(dat_SosciSurvey, function(x) {
structure( x, class = c("avector", class(x) ) )
} )
)mostattributes(dat_SosciSurvey_tmp) = attributes(dat_SosciSurvey)
= dat_SosciSurvey_tmp
dat_SosciSurvey rm(dat_SosciSurvey_tmp)
::datatable(dat_SosciSurvey, options = list(pageLength = 5)) DT
remove single person
Participant with ID “032” had not understood the task in a CAM and drew all neg. concepts on the left and all pos. concepts on the right.
Show CAMs
## ID 032 - wrong
plot(
"032"]],
CAMdrawn[[edge.arrow.size = .7,
layout = layout_nicely,
vertex.frame.color = "black",
asp = .5,
margin = -0.1,
vertex.size = 10,
vertex.label.cex = .9
)
## ID 032_2
plot(
"032_2"]],
CAMdrawn[[edge.arrow.size = .7,
layout = layout_nicely,
vertex.frame.color = "black",
asp = .5,
margin = -0.1,
vertex.size = 10,
vertex.label.cex = .9
)
Get right person (using time stamps)
## add 2 hours when transforming UTC to CET
unique(CAMfiles[[1]]$dateCAMcreated[CAMfiles[[1]]$participantCAM == "032"])
[1] "2024-03-18 08:16:04 UTC"
unique(CAMfiles[[1]]$dateCAMcreated[CAMfiles[[1]]$participantCAM == "032_2"])
[1] "2024-03-18 12:36:55 UTC"
$TE01_RV1 == "032" & !is.na(dat_SosciSurvey$TE01_RV1),"STARTED"] dat_SosciSurvey[dat_SosciSurvey
[1] "2024-03-18 09:41:36 CET" "2024-03-18 14:08:15 CET"
Remove participant from all files
### from raw CAM file
<- list(raw_CAM)
raw_CAM_clean = 1
h for(i in 1:length(raw_CAM)){
if(raw_CAM[[i]]$creator != "032"){
<- raw_CAM[[i]]
raw_CAM_clean[[h]] = h + 1
h
}
}
<- raw_CAM_clean
raw_CAM rm(raw_CAM_clean)
### from CAM files
1]] <- CAMfiles[[1]][!CAMfiles[[1]]$participantCAM %in% c("032"),]
CAMfiles[[2]] <- CAMfiles[[2]][!CAMfiles[[2]]$participantCAM %in% c("032"),]
CAMfiles[[3]] <- CAMfiles[[3]][!CAMfiles[[3]]$participantCAM.x %in% c("032"),]
CAMfiles[[
<- CAMdrawn[!names(CAMdrawn) %in% c("032")]
CAMdrawn
<- networkIndicators[!networkIndicators$participantCAM %in% c("032"),]
networkIndicators
<- neighborhood_networkIndicators[!neighborhood_networkIndicators$participantCAM %in% c("032"),]
neighborhood_networkIndicators
# re-create wordlist
<- create_wordlist(
CAMwordlist dat_nodes = CAMfiles[[1]],
dat_merged = CAMfiles[[3]],
useSummarized = TRUE,
order = "frequency",
splitByValence = FALSE,
comments = TRUE,
raterSubsetWords = NULL,
rater = FALSE
)
[1] "create_wordlist - use summarized words"
[1] 190
[1] 499
[1] "temporarily suffixes are added, because not all words have been summarized"
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
::datatable(CAMwordlist, options = list(pageLength = 5)) DT
### from SosciSurvey
nrow(dat_SosciSurvey)
[1] 77
<- dat_SosciSurvey[- c(which(dat_SosciSurvey$TE01_RV1 == "032")[1]),]
dat_SosciSurvey nrow(dat_SosciSurvey)
[1] 76
keep only socio survey data with matching CAMs IDs
$TE01_RV1[dat_SosciSurvey$TE01_RV1 == "032" & !is.na(dat_SosciSurvey$TE01_RV1)] <- "032_2"
dat_SosciSurvey<- dat_SosciSurvey[dat_SosciSurvey$TE01_RV1 %in% names(CAMdrawn),] dat_SosciSurvey
save CAMs as .json files, and as .png (igraph)
if(save_CAMs_as_pictures){
setwd("outputs")
setwd("savedCAMs")
setwd("png")
### remove all files if there are any
if(length(list.files()) >= 1){
file.remove(list.files())
cat('\n!
all former .png files have been deleted')
}
### if no participant ID was provided replace by randomly generated CAM ID
if(all(CAMfiles[[3]]$participantCAM.x == "noID")){
3]]$participantCAM.x <- CAMfiles[[3]]$CAM.x
CAMfiles[[
}
### save as .json files, and as .png (igraph)
<- unique(CAMfiles[[3]]$participantCAM.x); length(ids_CAMs)
ids_CAMs
for(i in 1:length(ids_CAMs)){
save_graphic(filename = paste0(ids_CAMs[i])) # paste0(ids_CAMs[i]))
<- CAMdrawn[[c(1:length(CAMdrawn))[
CAM_igraph names(CAMdrawn) == paste0(unique(CAMfiles[[3]]$participantCAM.x)[i])]]]
plot(CAM_igraph, edge.arrow.size = .7,
layout=layout_nicely, vertex.frame.color="black", asp = .5, margin = -0.1,
vertex.size = 10, vertex.label.cex = .9)
dev.off()
}
setwd("../json")
### remove all files if there are any
if(length(list.files()) >= 1){
file.remove(list.files())
cat('\n!
all former .json files have been deleted')
}for(i in 1:length(raw_CAM)){
if(!is_empty(raw_CAM[[i]]$nodes)){
if(nrow(raw_CAM[[i]]$nodes) > 5){
write(toJSON(raw_CAM[[i]], encoding = "UTF-8"),
paste0(raw_CAM[[i]]$idCAM, ".json"))
}
}
} }
create CAM files for single components
<- raw_CAM
raw_CAM_current <- raw_CAM
raw_CAM_past
### save CAMs
setwd("outputs/single components")
writeLines("", "CAMdata_current.txt") # create file
<- file("CAMdata_current.txt", "a") # open connection to append
text_connection_current
writeLines("", "CAMdata_past.txt") # create file
<- file("CAMdata_past.txt", "a") # open connection to append
text_connection_past
for(i in 1:length(CAMdrawn)){
<- CAMdrawn[[i]]
tmp_CAM
<- components(tmp_CAM)
com <- V(tmp_CAM)$name[V(tmp_CAM)$name %in% names(com$membership)[com$membership == 1]]
tmp_ids_1 <- V(tmp_CAM)$name[V(tmp_CAM)$name %in% names(com$membership)[com$membership == 2]]
tmp_ids_2
if("aktuelles Erleben im neuen Büro" %in% V(tmp_CAM)$label[V(tmp_CAM)$name %in% tmp_ids_1]){
<- tmp_ids_1
tmp_ids_current <- tmp_ids_2
tmp_ids_past else{
}<- tmp_ids_2
tmp_ids_current <- tmp_ids_1
tmp_ids_past
}
<- subgraph(graph = tmp_CAM, vids = tmp_ids_current)
tmp_CAM_current <- subgraph(graph = tmp_CAM, vids = tmp_ids_past)
tmp_CAM_past
# plot(tmp_CAM_current)
# cbind(raw_CAM[[i]]$connectors$source %in% V(tmp_CAM_current)$name,
# raw_CAM[[i]]$connectors$target %in% V(tmp_CAM_current)$name)
## keep only nodes / connectors for current:
$nodes <- raw_CAM_current[[i]]$nodes[raw_CAM_current[[i]]$nodes$id %in% V(tmp_CAM_current)$name, ]
raw_CAM_current[[i]]
$connectors <- raw_CAM_current[[i]]$connectors[raw_CAM_current[[i]]$connectors$source %in% V(tmp_CAM_current)$name, ]
raw_CAM_current[[i]]
# save
$creator <- paste0(raw_CAM_current[[i]]$creator, "_current") ## overwrite ID
raw_CAM_current[[i]]writeLines(jsonlite::toJSON(x = raw_CAM_current[[i]]), text_connection_current)
## keep only nodes / connectors for past:
$nodes <- raw_CAM_past[[i]]$nodes[raw_CAM_past[[i]]$nodes$id %in% V(tmp_CAM_past)$name, ]
raw_CAM_past[[i]]
$connectors <- raw_CAM_past[[i]]$connectors[raw_CAM_past[[i]]$connectors$source %in% V(tmp_CAM_past)$name, ]
raw_CAM_past[[i]]
# save
$creator <- paste0(raw_CAM_past[[i]]$creator, "_past") ## overwrite ID
raw_CAM_past[[i]]writeLines(jsonlite::toJSON(x = raw_CAM_past[[i]]), text_connection_past)
}
close(text_connection_current)
close(text_connection_past)
print("all CAMs saved")
[1] "all CAMs saved"
set up CAM data current
Create CAM files, draw CAMs and compute network indicators for current experiences
### create CAM single files (nodes, connectors, merged)
<- create_CAMfiles(datCAM = raw_CAM_current, reDeleted = TRUE) CAMfiles_current
Nodes and connectors, which were deleted by participants were removed.
# deleted nodes: 0
# deleted connectors: 10
### apply protocol
setwd("data")
<- readLines("protocol_v01.txt", warn = FALSE)
text <- readLines(textConnection(text, encoding = "UTF-8"), encoding = "UTF-8")
text
if (testIfJson(file = text)) {
<-
protocol ::fromJSON(file = "protocol_v01.txt")
rjson
## no CAM deleted
print(protocol$deletedCAMs)
<- overwriteTextNodes(protocolDat = protocol,
tmp_out nodesDat = CAMfiles_current[[1]])
1]] <- tmp_out[[1]]
CAMfiles_current[[# tmp_out[[2]]
else{
} print("Invalid protocol uploaded")
}
[1] "0a8e44bb-027d-4b3b-8b27-934860eb33e3"
time 2024-03-27 09:09:45.468222 at index 1 for approximate matching
time 2024-03-27 09:09:54.375455 at index 2 for approximate matching
time 2024-03-27 09:10:00.055962 at index 3 for approximate matching
time 2024-03-27 09:10:16.361624 at index 4 for approximate matching
time 2024-03-27 09:10:20.03996 at index 5 for approximate matching
time 2024-03-27 09:10:31.792348 at index 6 for approximate matching
time 2024-03-27 09:10:39.742539 at index 7 for approximate matching
time 2024-03-27 09:10:57.011727 at index 8 for approximate matching
time 2024-03-27 09:11:09.777395 at index 9 for approximate matching
time 2024-03-27 09:11:14.326505 at index 10 for approximate matching
time 2024-03-27 09:11:19.877418 at index 11 for approximate matching
time 2024-03-27 09:11:21.025896 at index 12 for approximate matching
time 2024-03-27 09:11:32.345376 at index 13 for approximate matching
time 2024-03-27 09:11:35.527045 at index 14 for approximate matching
time 2024-03-27 09:11:59.676772 at index 15 for approximate matching
time 2024-03-27 09:12:06.558638 at index 16 for approximate matching
time 2024-03-27 09:12:11.426233 at index 17 for approximate matching
time 2024-03-27 09:12:18.259098 at index 18 for approximate matching
time 2024-03-27 09:12:26.172405 at index 19 for approximate matching
time 2024-03-27 09:12:46.243045 at index 20 for approximate matching
time 2024-03-27 09:12:58.95868 at index 21 for approximate matching
time 2024-03-27 09:13:01.860362 at index 22 for approximate matching
time 2024-03-27 09:13:08.225296 at index 23 for approximate matching
time 2024-03-27 09:13:34.377537 at index 24 for approximate matching
time 2024-03-27 09:13:39.706119 at index 25 for approximate matching
time 2024-03-27 09:13:50.87323 at index 26 for approximate matching
time 2024-03-27 09:14:01.790417 at index 27 for approximate matching
time 2024-03-27 09:14:13.457764 at index 28 for approximate matching
time 2024-03-27 09:14:32.022188 at index 29 for approximate matching
time 2024-03-27 09:14:37.090642 at index 30 for approximate matching
time 2024-03-27 09:15:00.40541 at index 31 for approximate matching
time 2024-03-27 09:15:50.8418 at index 32 for approximate matching
time 2024-03-27 09:16:03.553642 at index 33 for approximate matching
time 2024-03-27 09:16:51.192392 at index 34 for approximate matching
time 2024-03-27 09:17:14.723674 at index 35 for approximate matching
time 2024-03-27 09:17:20.37401 at index 36 for approximate matching
time 2024-03-27 09:17:36.056367 at index 37 for approximate matching
time 2024-03-27 09:18:00.589159 at index 38 for approximate matching
time 2024-03-27 09:18:22.040034 at index 39 for approximate matching
time 2024-03-27 09:18:28.17327 at index 40 for approximate matching
time 2024-03-27 09:19:39.768021 at index 41 for approximate matching
time 2024-03-27 09:19:46.603037 at index 42 for approximate matching
time 2024-03-27 09:20:04.486784 at index 43 for approximate matching
time 2024-03-27 09:20:15.918261 at index 44 for approximate matching
time 2024-03-27 09:20:28.343038 at index 45 for approximate matching
time 2024-03-27 09:20:34.385201 at index 46 for approximate matching
time 2024-03-27 09:22:27.156596 at index 47 for search terms
time 2024-03-27 09:23:40.88302 at index 48 for search terms
time 2024-03-27 09:26:02.514854 at index 49 for search terms
time 2024-03-27 09:27:28.79977 at index 50 for search terms
time 2024-03-27 09:28:24.113472 at index 51 for search terms
time 2024-03-27 09:31:02.480129 at index 52 for search terms
time 2024-03-27 09:32:21.027863 at index 53 for search terms
time 2024-03-27 09:33:50.364135 at index 54 for search terms
time 2024-03-27 09:35:53.259618 at index 55 for search terms
time 2024-03-27 09:38:59.688684 at index 56 for search terms
time 2024-03-27 09:41:31.539652 at index 57 for search terms
time 2024-03-27 09:44:08.538553 at index 58 for search terms
time 2024-03-27 09:44:39.619148 at index 59 for search terms
time 2024-03-27 09:45:13.460504 at index 60 for search terms
time 2024-03-27 09:49:27.390569 at index 61 for search terms
time 2024-03-27 09:50:02.809324 at index 62 for search terms
time 2024-03-27 09:50:31.324591 at index 63 for search terms
time 2024-03-27 09:51:16.39256 at index 64 for search terms
time 2024-03-27 09:54:59.443253 at index 65 for search terms
time 2024-03-27 09:58:00.931791 at index 66 for search terms
time 2024-03-27 09:58:31.5607 at index 67 for search terms
time 2024-03-27 09:59:24.044396 at index 68 for search terms
time 2024-03-27 10:00:18.76173 at index 69 for search terms
time 2024-03-27 10:01:07.70914 at index 70 for search terms
time 2024-03-27 10:01:58.763652 at index 71 for search terms
time 2024-03-27 10:03:12.667148 at index 72 for search terms
time 2024-03-27 10:05:50.349782 at index 73 for search terms
time 2024-03-27 10:07:57.996942 at index 74 for search terms
time 2024-03-27 10:08:57.895383 at index 75 for search terms
time 2024-03-27 10:10:52.07574 at index 76 for search terms
time 2024-03-27 10:11:38.249778 at index 77 for search terms
time 2024-03-27 10:15:13.535888 at index 78 for search terms
time 2024-03-27 10:16:53.302933 at index 79 for search terms
time 2024-03-27 10:18:33.287615 at index 80 for search terms
### draw CAMs
<- draw_CAM(dat_merged = CAMfiles_current[[3]],
CAMdrawn_current dat_nodes = CAMfiles_current[[1]],ids_CAMs = "all",
plot_CAM = FALSE,
useCoordinates = TRUE,
relvertexsize = 3,
reledgesize = 1)
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
### network indicators
<- NULL
tmp_microIndicator <- compute_indicatorsCAM(drawn_CAM = CAMdrawn_current,
networkIndicators_current micro_degree = tmp_microIndicator,
micro_valence = tmp_microIndicator,
micro_centr_clo = tmp_microIndicator,
micro_transitivity = tmp_microIndicator,
largestClique = FALSE)
### wordlist
<- create_wordlist(
CAMwordlist_current dat_nodes = CAMfiles_current[[1]],
dat_merged = CAMfiles_current[[3]],
useSummarized = TRUE,
order = "frequency",
splitByValence = FALSE,
comments = TRUE,
raterSubsetWords = NULL,
rater = FALSE
)
[1] "create_wordlist - use summarized words"
[1] 95
[1] 276
[1] "temporarily suffixes are added, because not all words have been summarized"
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
::datatable(CAMwordlist_current, options = list(pageLength = 5)) DT
aggregate CAMs
<- unique(CAMfiles_current[[1]]$participantCAM)
sel_ids
<- CAMfiles_current[[1]]
tmp_nodes
$text_summarized <- str_remove(string = tmp_nodes$text_summarized, pattern = "_positive$|_negative$|_neutral$|_ambivalent$")
tmp_nodes$text_summarized <- str_trim(string = tmp_nodes$text_summarized)
tmp_nodes
<- tmp_nodes
tmp_nodes_high $group <- "high"
tmp_nodes_high
<- aggregate_CAMs(dat_merged = CAMfiles_current[[3]], dat_nodes = tmp_nodes,
CAMaggregated ids_CAMs = sel_ids)
[1] "aggregate_CAMs: using participant CAM ids"
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
[1] "text_summarized column identified"
# plot(CAMaggregated[[2]], vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*20, edge.arrow.size=0.01)
# plot(CAMaggregated[[2]], vertex.size=(abs(V(CAMaggregated[[2]])$value)+1)*5, edge.arrow.size=0.01)
= CAMaggregated[[2]]
g = simplify(CAMaggregated[[2]])
g2 # plot(g2, edge.arrow.size=0.01,
# vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*20)
E(g2)$weight = sapply(E(g2), function(e) {
length(all_shortest_paths(g, from=ends(g2, e)[1], to=ends(g2, e)[2])$res) } )
E(g2)$weight = E(g2)$weight / 2
# E(g2)$weight[E(g2)$weight == 1] <- NA
V(g2)$color[V(g2)$value <= .5 & V(g2)$value >= -.5] <- "yellow"
V(g2)$shape <- NA
V(g2)$shape <- ifelse(test = V(g2)$color == "yellow", yes = "square", no = "circle")
### > plot multiple times because of random layout
for(i in 1:5){
plot(g2, edge.arrow.size = 0,
layout=layout_nicely, vertex.frame.color="black", asp = .5, margin = -0.1,
vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*5,
vertex.label.cex = .9,
edge.weight=2, edge.width=(E(g2)$weight/3))
}
set up CAM data past experiences
Create CAM files, draw CAMs and compute network indicators for past experiences
### create CAM single files (nodes, connectors, merged)
<- create_CAMfiles(datCAM = raw_CAM_past, reDeleted = TRUE) CAMfiles_past
Nodes and connectors, which were deleted by participants were removed.
# deleted nodes: 0
# deleted connectors: 11
### apply protocol
setwd("data")
<- readLines("protocol_v01.txt", warn = FALSE)
text <- readLines(textConnection(text, encoding = "UTF-8"), encoding = "UTF-8")
text
if (testIfJson(file = text)) {
<-
protocol ::fromJSON(file = "protocol_v01.txt")
rjson
## no CAM deleted
print(protocol$deletedCAMs)
<- overwriteTextNodes(protocolDat = protocol,
tmp_out nodesDat = CAMfiles_past[[1]])
1]] <- tmp_out[[1]]
CAMfiles_past[[# tmp_out[[2]]
else{
} print("Invalid protocol uploaded")
}
[1] "0a8e44bb-027d-4b3b-8b27-934860eb33e3"
time 2024-03-27 09:09:45.468222 at index 1 for approximate matching
time 2024-03-27 09:09:54.375455 at index 2 for approximate matching
time 2024-03-27 09:10:00.055962 at index 3 for approximate matching
time 2024-03-27 09:10:16.361624 at index 4 for approximate matching
time 2024-03-27 09:10:20.03996 at index 5 for approximate matching
time 2024-03-27 09:10:31.792348 at index 6 for approximate matching
time 2024-03-27 09:10:39.742539 at index 7 for approximate matching
time 2024-03-27 09:10:57.011727 at index 8 for approximate matching
time 2024-03-27 09:11:09.777395 at index 9 for approximate matching
time 2024-03-27 09:11:14.326505 at index 10 for approximate matching
time 2024-03-27 09:11:19.877418 at index 11 for approximate matching
time 2024-03-27 09:11:21.025896 at index 12 for approximate matching
time 2024-03-27 09:11:32.345376 at index 13 for approximate matching
time 2024-03-27 09:11:35.527045 at index 14 for approximate matching
time 2024-03-27 09:11:59.676772 at index 15 for approximate matching
time 2024-03-27 09:12:06.558638 at index 16 for approximate matching
time 2024-03-27 09:12:11.426233 at index 17 for approximate matching
time 2024-03-27 09:12:18.259098 at index 18 for approximate matching
time 2024-03-27 09:12:26.172405 at index 19 for approximate matching
time 2024-03-27 09:12:46.243045 at index 20 for approximate matching
time 2024-03-27 09:12:58.95868 at index 21 for approximate matching
time 2024-03-27 09:13:01.860362 at index 22 for approximate matching
time 2024-03-27 09:13:08.225296 at index 23 for approximate matching
time 2024-03-27 09:13:34.377537 at index 24 for approximate matching
time 2024-03-27 09:13:39.706119 at index 25 for approximate matching
time 2024-03-27 09:13:50.87323 at index 26 for approximate matching
time 2024-03-27 09:14:01.790417 at index 27 for approximate matching
time 2024-03-27 09:14:13.457764 at index 28 for approximate matching
time 2024-03-27 09:14:32.022188 at index 29 for approximate matching
time 2024-03-27 09:14:37.090642 at index 30 for approximate matching
time 2024-03-27 09:15:00.40541 at index 31 for approximate matching
time 2024-03-27 09:15:50.8418 at index 32 for approximate matching
time 2024-03-27 09:16:03.553642 at index 33 for approximate matching
time 2024-03-27 09:16:51.192392 at index 34 for approximate matching
time 2024-03-27 09:17:14.723674 at index 35 for approximate matching
time 2024-03-27 09:17:20.37401 at index 36 for approximate matching
time 2024-03-27 09:17:36.056367 at index 37 for approximate matching
time 2024-03-27 09:18:00.589159 at index 38 for approximate matching
time 2024-03-27 09:18:22.040034 at index 39 for approximate matching
time 2024-03-27 09:18:28.17327 at index 40 for approximate matching
time 2024-03-27 09:19:39.768021 at index 41 for approximate matching
time 2024-03-27 09:19:46.603037 at index 42 for approximate matching
time 2024-03-27 09:20:04.486784 at index 43 for approximate matching
time 2024-03-27 09:20:15.918261 at index 44 for approximate matching
time 2024-03-27 09:20:28.343038 at index 45 for approximate matching
time 2024-03-27 09:20:34.385201 at index 46 for approximate matching
time 2024-03-27 09:22:27.156596 at index 47 for search terms
time 2024-03-27 09:23:40.88302 at index 48 for search terms
time 2024-03-27 09:26:02.514854 at index 49 for search terms
time 2024-03-27 09:27:28.79977 at index 50 for search terms
time 2024-03-27 09:28:24.113472 at index 51 for search terms
time 2024-03-27 09:31:02.480129 at index 52 for search terms
time 2024-03-27 09:32:21.027863 at index 53 for search terms
time 2024-03-27 09:33:50.364135 at index 54 for search terms
time 2024-03-27 09:35:53.259618 at index 55 for search terms
time 2024-03-27 09:38:59.688684 at index 56 for search terms
time 2024-03-27 09:41:31.539652 at index 57 for search terms
time 2024-03-27 09:44:08.538553 at index 58 for search terms
time 2024-03-27 09:44:39.619148 at index 59 for search terms
time 2024-03-27 09:45:13.460504 at index 60 for search terms
time 2024-03-27 09:49:27.390569 at index 61 for search terms
time 2024-03-27 09:50:02.809324 at index 62 for search terms
time 2024-03-27 09:50:31.324591 at index 63 for search terms
time 2024-03-27 09:51:16.39256 at index 64 for search terms
time 2024-03-27 09:54:59.443253 at index 65 for search terms
time 2024-03-27 09:58:00.931791 at index 66 for search terms
time 2024-03-27 09:58:31.5607 at index 67 for search terms
time 2024-03-27 09:59:24.044396 at index 68 for search terms
time 2024-03-27 10:00:18.76173 at index 69 for search terms
time 2024-03-27 10:01:07.70914 at index 70 for search terms
time 2024-03-27 10:01:58.763652 at index 71 for search terms
time 2024-03-27 10:03:12.667148 at index 72 for search terms
time 2024-03-27 10:05:50.349782 at index 73 for search terms
time 2024-03-27 10:07:57.996942 at index 74 for search terms
time 2024-03-27 10:08:57.895383 at index 75 for search terms
time 2024-03-27 10:10:52.07574 at index 76 for search terms
time 2024-03-27 10:11:38.249778 at index 77 for search terms
time 2024-03-27 10:15:13.535888 at index 78 for search terms
time 2024-03-27 10:16:53.302933 at index 79 for search terms
time 2024-03-27 10:18:33.287615 at index 80 for search terms
### draw CAMs
<- draw_CAM(dat_merged = CAMfiles_past[[3]],
CAMdrawn_past dat_nodes = CAMfiles_past[[1]],ids_CAMs = "all",
plot_CAM = FALSE,
useCoordinates = TRUE,
relvertexsize = 3,
reledgesize = 1)
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
### network indicators
<- NULL
tmp_microIndicator <- compute_indicatorsCAM(drawn_CAM = CAMdrawn_past,
networkIndicators_past micro_degree = tmp_microIndicator,
micro_valence = tmp_microIndicator,
micro_centr_clo = tmp_microIndicator,
micro_transitivity = tmp_microIndicator,
largestClique = FALSE)
### wordlist
<- create_wordlist(
CAMwordlist_past dat_nodes = CAMfiles_past[[1]],
dat_merged = CAMfiles_past[[3]],
useSummarized = TRUE,
order = "frequency",
splitByValence = FALSE,
comments = TRUE,
raterSubsetWords = NULL,
rater = FALSE
)
[1] "create_wordlist - use summarized words"
[1] 95
[1] 223
[1] "temporarily suffixes are added, because not all words have been summarized"
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
::datatable(CAMwordlist_past, options = list(pageLength = 5)) DT
aggregate CAMs
<- unique(CAMfiles_past[[1]]$participantCAM)
sel_ids
<- CAMfiles_past[[1]]
tmp_nodes
$text_summarized <- str_remove(string = tmp_nodes$text_summarized, pattern = "_positive$|_negative$|_neutral$|_ambivalent$")
tmp_nodes$text_summarized <- str_trim(string = tmp_nodes$text_summarized)
tmp_nodes
<- tmp_nodes
tmp_nodes_high $group <- "high"
tmp_nodes_high
<- aggregate_CAMs(dat_merged = CAMfiles_past[[3]], dat_nodes = tmp_nodes,
CAMaggregated ids_CAMs = sel_ids)
[1] "aggregate_CAMs: using participant CAM ids"
processing 28 CAMs...
[1] "== participantCAM in drawnCAM"
[1] "text_summarized column identified"
# plot(CAMaggregated[[2]], vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*20, edge.arrow.size=0.01)
# plot(CAMaggregated[[2]], vertex.size=(abs(V(CAMaggregated[[2]])$value)+1)*5, edge.arrow.size=0.01)
= CAMaggregated[[2]]
g = simplify(CAMaggregated[[2]])
g2 # plot(g2, edge.arrow.size=0.01,
# vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*20)
E(g2)$weight = sapply(E(g2), function(e) {
length(all_shortest_paths(g, from=ends(g2, e)[1], to=ends(g2, e)[2])$res) } )
E(g2)$weight = E(g2)$weight / 2
# E(g2)$weight[E(g2)$weight == 1] <- NA
V(g2)$color[V(g2)$value <= .5 & V(g2)$value >= -.5] <- "yellow"
V(g2)$shape <- NA
V(g2)$shape <- ifelse(test = V(g2)$color == "yellow", yes = "square", no = "circle")
### > plot multiple times because of random layout
for(i in 1:5){
plot(g2, edge.arrow.size = 0,
layout=layout_nicely, vertex.frame.color="black", asp = .5, margin = -0.1,
vertex.size=diag(CAMaggregated[[1]]) / max(diag(CAMaggregated[[1]]))*5,
vertex.label.cex = .9,
edge.weight=2, edge.width=(E(g2)$weight/3))
}
Analyses
within t-Tests
cbind(networkIndicators_current$participantCAM, networkIndicators_past$participantCAM)
[,1] [,2]
[1,] "014_current" "014_past"
[2,] "025_current" "025_past"
[3,] "028_current" "028_past"
[4,] "030_current" "030_past"
[5,] "029_current" "029_past"
[6,] "031_current" "031_past"
[7,] "032_2_current" "032_2_past"
[8,] "019_current" "019_past"
[9,] "021_current" "021_past"
[10,] "022_current" "022_past"
[11,] "017_current" "017_past"
[12,] "018_current" "018_past"
[13,] "024_current" "024_past"
[14,] "020_current" "020_past"
[15,] "026_current" "026_past"
[16,] "001_current" "001_past"
[17,] "003_current" "003_past"
[18,] "008_current" "008_past"
[19,] "005_current" "005_past"
[20,] "006_current" "006_past"
[21,] "007_current" "007_past"
[22,] "002_current" "002_past"
[23,] "009_current" "009_past"
[24,] "010_current" "010_past"
[25,] "011_current" "011_past"
[26,] "013_current" "013_past"
[27,] "015_current" "015_past"
[28,] "012_current" "012_past"
$type <- "current experiences"
networkIndicators_current$type <- "past experiences"
networkIndicators_past
<- rbind(networkIndicators_current, networkIndicators_past)
networkIndicators_long
library(ggstatsplot)
## parametric t-test for mean valence
ggwithinstats(
data = networkIndicators_long,
x = type,
y = mean_valence_macro,
type = "p",
effsize.type = "d",
conf.level = 0.99,
title = "Parametric t-test for mean valence"
)
Warning in min(x): kein nicht-fehlendes Argument für min; gebe Inf zurück
Warning in max(x): kein nicht-fehlendes Argument für max; gebe -Inf zurück
$participantCAM[networkIndicators_current$mean_valence_macro - networkIndicators_past$mean_valence_macro < 0] networkIndicators_current
[1] "029_current" "031_current" "021_current" "017_current" "018_current"
[6] "024_current" "001_current" "003_current" "008_current" "005_current"
[11] "002_current" "009_current" "010_current" "011_current" "015_current"
$participantCAM[networkIndicators_current$mean_valence_macro - networkIndicators_past$mean_valence_macro > 0] networkIndicators_current
[1] "014_current" "025_current" "028_current" "030_current"
[5] "032_2_current" "019_current" "022_current" "020_current"
[9] "026_current" "006_current" "007_current" "013_current"
[13] "012_current"
## parametric t-test for number of concepts
ggwithinstats(
data = networkIndicators_long,
x = type,
y = num_nodes_macro,
type = "p",
effsize.type = "d",
conf.level = 0.99,
title = "Parametric t-test for number of concepts"
)
Warning in min(x): kein nicht-fehlendes Argument für min; gebe Inf zurück
Warning in min(x): kein nicht-fehlendes Argument für max; gebe -Inf zurück
## parametric t-test for number of concepts
ggwithinstats(
data = networkIndicators_long,
x = type,
y = num_nodes_pos_macro,
type = "p",
effsize.type = "d",
conf.level = 0.99,
title = "Parametric t-test for number of concepts positive"
)
Warning in min(x): kein nicht-fehlendes Argument für min; gebe Inf zurück
Warning in min(x): kein nicht-fehlendes Argument für max; gebe -Inf zurück
## parametric t-test for number of concepts
ggwithinstats(
data = networkIndicators_long,
x = type,
y = num_nodes_neg_macro,
type = "p",
effsize.type = "d",
conf.level = 0.99,
title = "Parametric t-test for number of concepts negative"
)
Warning in min(x): kein nicht-fehlendes Argument für min; gebe Inf zurück
Warning in min(x): kein nicht-fehlendes Argument für max; gebe -Inf zurück
save data sets
### save data set
setwd("outputs")
## save as .xlsx file
::write.xlsx2(x = dat_SosciSurvey, file = "dat_SosciSurvey.xlsx")
xlsx## save as .csv file
write.csv2(x = dat_SosciSurvey, file = "dat_SosciSurvey.csv")
## save as R object
saveRDS(dat_SosciSurvey, file = "dat_SosciSurvey.rds")