forked from CrumpLab/LabJournalWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlots.Rmd
More file actions
116 lines (78 loc) · 2.66 KB
/
Plots.Rmd
File metadata and controls
116 lines (78 loc) · 2.66 KB
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
---
title: "Plots"
output:
html_document:
toc: true
toc_float: true
collapsed: false
number_sections: false
toc_depth: 1
#code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, messages=TRUE, error=TRUE)
```
#Problem 1
```{r}
#Dataframe
Names<-rep(c("Dara","Rita","Liza","Azalea","Barbi", "Rowena", "Fiona", "Katie"),each=2)
Adversity<-rep(c("Not_Advers","Advers"),times=c(6,10))
Conditions<-rep(c("Social","Not_Social"),8)
MeanFreq<-runif(16,1,70)
A<-data.frame(Names,Adversity,Conditions,MeanFreq)
#ggplot
ggplot(A,aes(x=Conditions,y=MeanFreq,group=Names,linetype=Adversity))+geom_line()+geom_text(label=Names)+theme_classic()
```
#Problem 2
```{r,eval=FALSE}
#Dataframe
Aver_Freq_SC<-rnorm(7,35,70)
Aver_Freq_NonSC<-rnorm(7,35,70)
B<-data.frame(Aver_Freq_SC,Aver_Freq_NonSC)
#ggplot
ggplot(B,aes(x=Aver_Freq_NonSC,y=Aver_Freq_SC))+
geom_point()+geom_smooth(method=lm)
```
#Problem 3
```{r,eval=FALSE}
#Create a dataframe
X_Axis<-as.factor(c("Doctor Study 1 N=199", "Butcher Study 2 n=199", "Firefighter Study 2 n=200", "Construction Worker Study 2 n=2"))
Stacked_factors<-as.factor(c("Man More Likely", "Equal Likely", "Women More Likely", "NnAa"))
"Man More Likely"<-c(7,35,40,40)
"Equal Likely"<-c(93,60,59,57)
"Women More Likely"<-c(0,5,1,3)
"NnAa"<-c(0,0,0,0)
Percentage_of_Participants<-sample(0:100,replace = T)
Data_C<-data.frame(X_Axis,Stacked_factors,Percentage_of_Participants)
# basic bar graph
ggplot(Data_C)+ geom_bar(aes(x=X_Axis, fill=Stacked_factors))
ggplot(Data_C, aes(x=X_Axis,y=Percentage_of_Participants))+
geom_bar(stat="identity")+
geom_errorbar(aes(ymin=Percentage_of_Participants-Stacked_factors,
ymax=Percentage_of_Participants+Stacked_factors), width=.2)+
coord_cartesian(ylim=c(0,100))+
xlab("X_Axis")+
ylab("Stacked_factors")+
theme_classic(base_size=12)+
theme(plot.title = element_text(hjust = 0.5))
```
#Problem 4
```{r,eval=FALSE}
#Create a dataframe
Person_X_Answer<- as.factor(c("Equal Likely n=200","Man More Likely n=202", "NaNa"))
Money_Transferred_to_Person_X<-as.factor(c(0.00,0.15,0.30))
Data_D<-data.frame(Person_X_Answer,Money_Transferred_to_Person_X)
# basic bar graph
ggplot(Data_D, aes(x=Person_X_Answer,y=Money_Transferred_to_Person_X))+
geom_bar(stat="identity")+
geom_errorbar(aes(ymin=Person_X_Answer-Money_Transferred_to_Person_X,
ymax=Person_X_Answer+Mone
y_Transferred_to_Person_X),
width=.2)+
coord_cartesian(ylim=c(0,100))+
xlab(Person_X_Answer)+
ylab(Money_Transferred_to_Person_X)+
ggtitle("Bar graph with Error Bars")+
theme_classic(base_size=12)+
theme(plot.title = element_text(hjust = 0.5))
```