-
Notifications
You must be signed in to change notification settings - Fork 0
/
dm_survey_clean_data.R
59 lines (50 loc) · 3.02 KB
/
dm_survey_clean_data.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
library(ggplot2)
library(scales)
d <- read.csv("~/Documents/dm_survey_data/dm_survey.csv")
d <- d[d[7] != "",]
# rename columns
names(d) <- c("Timestamp","Frequency of Games","Length of Games","Locations Played",
"Primary Locations","Campaign Worlds","Adventures",
"Preferred Combat Type","Preparation Time","Campaign and Worldbuilding",
"Story and Adventures","Combat Encounters","NPC Development",
"Exploration and Roleplay","Treasure and Magic Items","Prop and Handouts",
"Top Three Tools","Favorite Trick")
# Convert factors to characters
d[] <- lapply(d, as.character)
# Rename values for brevity
d[d=="Once a week"] <- "Weekly"
d[d=="Once a month"] <- "Monthly"
d[d=="Twice a month"] <- "Twice monthly"
d[d=="More than twice a week"] <- "More than twice weekly"
d[d=="I primarily run D&D games at home"] <- "Home"
d[d=="I primarily run D&D games online using Roll20"] <- "Roll20"
d[d=="I run a relatively equal mix of multiple methods"] <- "Equal mix"
d[d=="I primarily run D&D games at another private location"] <- "Another private location"
d[d=="I primarily run D&D games at a local game shop"] <- "Local game shop"
d[d=="I primarily run D&D games at another public location"] <- "Another public Location"
d[d=="I primarily run D&D games online using another tool"] <- "Another online tool"
d[d=="I primarily run D&D games online using Fantasy Grounds"] <- "Fantasy Grounds"
d[d=="Another D&D campaign world such as Eberron, Dark Sun, or Greyhawk"] <- "Another D&D Campaign World"
d[d=="Another Published Campaign World that isn't a traditional D&D campaign setting"] <- "Non-D&D Campaign World"
d[d=="My own personal setting"] <- "Personal setting"
d[d=="I primarily run published adventures"] <- "Published adventures"
d[d=="I primarily run my own adventures"] <- "Personal adventures"
d[d=="I prefer to use abstract maps and general positioning but without a grid."] <- "Abstract maps"
d[d=="I prefer to run narrative \"theater of the mind\" combat."] <- "Theater of the Mind"
d[d=="I prefer to run combat with maps, miniatures, and five foot per square grids."] <- "5' gridded combat"
d["Adventures"][d["Adventures"] == ""] <- "No answer"
keeps <- c("Frequency of Games","Length of Games","Locations Played",
"Primary Locations","Campaign Worlds","Adventures",
"Preferred Combat Type","Preparation Time","Campaign and Worldbuilding",
"Story and Adventures","Combat Encounters","NPC Development",
"Exploration and Roleplay","Treasure and Magic Items","Prop and Handouts",
"Top Three Tools","Favorite Trick")
d <- d[keeps]
total_rows <- nrow(d)
total_potential_dupes <- total_rows - nrow(unique(d))
# Remove duplicate rows except those where text fields were blank.
c <- d[d["Top Three Tools"] == "" & d["Favorite Trick"] == "",]
d <- d[!d["Top Three Tools"] == "" | !d["Favorite Trick"] == "",]
d <- rbind(unique(d),c)
potential_dupes <- total_rows - nrow(d)
write.csv(d, file = "~/Documents/dm_survey_data/dm_survey_clean.csv", row.names=FALSE)