forked from focods/dataExplainedProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsandbox.R
More file actions
50 lines (39 loc) · 1.6 KB
/
Copy pathsandbox.R
File metadata and controls
50 lines (39 loc) · 1.6 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
library(tidyverse)
library(ggplot2)
library(plotly)
data = read.csv('edge1.1.csv')
head(data,2)
# Select variables wanted for initial analysis / regression
# "Participated" is created because every entry in the initial data frame is considered to have participated in the conversationh
df = data %>%
select(ThreadId,Id_num,Male,Female,FemaleParticipation) %>%
mutate(participated = 1)
#Create a unique ID in order to bring IDs of Thread and User together
df$new.id = paste(df$Id_num,df$ThreadId,sep='-')
####################################################################################################
#### This portion needs massive amounts of help - slow but works ####
# Creating a dataframe which iterates through and associates a Thread ID with Every single User ID
# This will be used to merge in order to associate zeros for "participated"
###
#Create lists of uniques in order to iterate through
u.Id_num = unique(df$Id_num)
u.ThreadId = unique(df$ThreadId)
a = data.frame(x=0,y=0)
b = data.frame(x=0,y=0)
for(j in 1:length(u.ThreadId)){
b = rbind(b,a)
a = data.frame(x=0,y=0)
for(i in 1:length(u.Id_num)){
a[i,1] = u.Id_num[i]
a[i,2] = u.ThreadId[j]
}
}
c = b[3:nrow(b),]
c$new.id = paste(c$x,c$y,sep='-')
d = merge(df,c,by='new.id',all=TRUE)
d[is.na(d)] = 0
####################################################################################################
# Creating the "final data frame" which has
final.df = d %>%
mutate(PARTICIPATION.CALCULATION = Female * participated * FemaleParticipation) %>%
select(ThreadId,Id_num,Male,Female,FemaleParticipation,PARTICIPATION.CALCULATION)