-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilter Raw Data.R
47 lines (35 loc) · 1.39 KB
/
Filter Raw 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
# This R script gets rid of the "Rectangle" variables and binds the timestamp from the original Eye tracking data
setwd("/Users/csanabria/Dropbox/Data\ Science/UCI/Eye\ Tracking/Raw\ Data")
#File Name with no extension. Extension has to be CSV.
InputFileName_Data = "Midtest\ Form\ B\ 112917"
InputFileName_TimeStamp = "midtest\ B\ timstamp"
# DONT CHANGE BELOW
rawdata <- read.table(
file = paste(InputFileName_Data, ".CSV", sep = ""),
header = TRUE,
sep = ","
)
filtered_data <- rawdata[ , -which(startsWith(names(rawdata),"AOI.Rectangle"))]
timestamp_data <- read.table(
file = paste(InputFileName_TimeStamp, ".CSV", sep = ""),
header = TRUE,
sep = ","
)
library(dplyr)
timestamp_data <- filter(
.data = timestamp_data,
RecordingTimestamp > 0
)
filtered_data <- cbind(filtered_data, timestamp_data[,"RecordingTimestamp"])
colnames(filtered_data)[length(colnames(filtered_data))] <- "RecordingTimestamp"
filtered_data <- mutate(
.data = filtered_data,
ParticipantNameShort = as.integer(sapply(strsplit(as.character(ParticipantName), "_"), "[", 2))
)
filtered_data <- filtered_data[ , -which(names(filtered_data) %in% c("ParticipantName"))]
colnames(filtered_data)[length(colnames(filtered_data))] <- "ParticipantName"
colnames(filtered_data)[1] <- "Form"
write.csv(filtered_data,
file = paste(InputFileName_Data, "\ filtered\ by\ R.csv", sep = ""),
row.names = FALSE
)