-
Notifications
You must be signed in to change notification settings - Fork 0
/
QualAnalysis2.R
126 lines (99 loc) · 4.95 KB
/
QualAnalysis2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
setwd("~/Projects/TouchExp/MainStudy/Rscript2/TouchExp")
path1 <- getwd()
df3 <- read.csv("ConvertedTouchScores5.csv")
NuCond1 <- rep(c("Positive"),each=150)
df3[1:150,76] <- NuCond1
NuCond2 <- rep(c("Negative"),each=150)
df3[151:300,76] <- NuCond2
library(tibble)
library(dplyr)
library(ggplot2)
library(forcats)
library(ggthemes)
library(reshape)
attach(df3)
for (u in 1:nrow(df3)){
if (df3[u,23] == "RestaurantBar"){
df3[u,23] <- "Restaurant/Bar"
}
}
#Plot LocLabl by condition
# apply the summation per value
LocNam <- c("Work", "Work","Restaurant/Bar","Restaurant/Bar","Other's home",
"Other's home", "Public Building", "Public Building", "Street",
"Street","Vehicle","Vehicle", "Other", "Other",
"Public outside area", "Public outside area","Home","Home")
LocVal <- c(8,52,9,35,7,10,7,10,6,10,2,4,2,2,12,5,97,32)
LocCond <- c('Positive','Negative','Positive','Negative','Positive','Negative',
'Positive','Negative','Positive','Negative','Positive','Negative',
'Positive','Negative','Positive','Negative','Positive','Negative')
LocDf <- data.frame(LocNam,LocVal,LocCond)
LocDf$LocNam <- factor(LocDf$LocNam,levels = c("Work","Restaurant/Bar",
"Other's home","Public Building",
"Street","Vehicle", "Other",
"Public outside area", "Home"))
ggplot(LocDf,aes(x=LocNam, y=LocVal, fill = LocCond))+
geom_bar(stat = "identity",position = position_dodge())+
labs(fill = "Touch experience", y = "Count", x = "")+
scale_y_continuous(breaks=seq(0,100,10),expand = c(0.02, 0), limits=c(0,100))+
theme(axis.text.x = element_text(angle = 45,hjust = 1, size = 14),
axis.title.y = element_text(size = 18),
legend.position = c(0.4, 0.8), axis.text.y=element_text(size=14),
legend.title = element_text(size=18),legend.text = element_text(size=16),
plot.margin = margin(t = 20,r = 20,b = 15,l = 15))+
scale_fill_colorblind()+
guides(fill = guide_legend(reverse=TRUE))
ggsave(filename = "LocationByCondition3.tif",path = path1, width = 7, height = 7, device='tiff', dpi=300)
#Plot IntLabl for each condition, not combined
# Group A, aka. positive group
table(df3[1:150,7])
Cond1 <- rep(c("A"),each=21)
IntLablNam <- c("Comfort","Affection","Greeting/Farewell","Reunion","Support",
"Care","Induce/Express joy","Intimacy/Closeness","Friendly",
"Appreciation/Gratitude","Sexual desire","Celebration/Congratulation",
"Reaffirmation","Pride","Flirty","Consolidation",
"Apologize","Sympathy","Respect","Relax","Other")
IntLablNam <- factor(IntLablNam,levels=IntLablNam)
IntVarNum <- c(35,30,25,10,8,7,6,5,4,3,2,1,1,1,1,1,1,1,1,1,5)
IntPosFram <- data.frame(IntVarNum,IntLablNam,Cond1)
attach(IntPosFram)
ggplot(IntPosFram,aes(x = IntLablNam, y=IntVarNum))+
geom_bar(stat="identity",aes(fill=Cond1),width=0.9)+
labs(y = "Count", x = "")+
theme(axis.text.x = element_text(angle = 60,hjust = 1.05),
axis.title.y = element_text(size = 16),
legend.position = c(0.8, 0.8), axis.text=element_text(size=12),
legend.title = element_text(size=16),
legend.text = element_text(size=12),
plot.margin = margin(t = 20,r = 20,b = 10,l = 15))+
scale_y_continuous(breaks=seq(0,40,5),expand = c(0.01, 0),limits=c(0,40))+
scale_fill_discrete(labels=c('Positive'))+
labs(fill = "Touch experience")
# Group B, aka. negative group
table(df3[151:300,7])
Cond2 <- rep(c("B"),each=30)
IntLablNam2 <- c("Greeting/Farewell","Friendly","Affection","Comfort",
"Sexual desire","Flirty","Be funny",
"Capture attention","Appreciation/gratitude","Attraction",
"Intimacy/closeness","Save time","Harm","Support","Accidental",
"Truce",
"Stop movement","Congratulation/Celebration","Induce reaction","Solidarity",
"Care","Steal","Protect","Alienate","Recognition","Reunion",
"Sympathy","Make contact","Therapeutic","Other")
IntLablNam2 <- factor(IntLablNam2,levels=IntLablNam2)
IntVarNum2 <- c(48,17,10,9,6,5,4,3,3,3,3,3,
3,3,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,8)
IntNegFram <- data.frame(IntVarNum2,IntLablNam2,Cond2)
attach(IntNegFram)
ggplot(IntNegFram,aes(x = IntLablNam2, y=IntVarNum2))+
geom_bar(stat="identity",aes(fill=Cond2),width = 0.9)+
labs(y = "Count", x = "")+
theme(axis.text.x = element_text(angle = 60,hjust = 1.05),
axis.title.y = element_text(size = 16),
legend.position = c(0.8, 0.8), axis.text=element_text(size=12),
legend.title = element_text(size=16),
legend.text = element_text(size=12),
plot.margin = margin(t = 20,r = 20,b = 10,l = 15))+
scale_y_continuous(breaks=seq(0,50,5),expand = c(0.01, 0),limits=c(0,50))+
scale_fill_manual(values=c("#619CFF"),name = "Touch experience",
labels=c('Negative'))