-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_transcripts.R
28 lines (20 loc) · 1.41 KB
/
clean_transcripts.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
library(tidyverse)
getCSVfromTranscript <- function(file = '~/cloud/gdrive/fire_project/local_data/field_validation/B64_transcript.txt',
plotID, makeCSV = F){
transcript <- read_file(file)
transcript <- gsub(pattern = c("conifer|say|charlie|Charlie|callfor|Drive|Charly|Charlene|charlene") ,replacement = "C",x = transcript)
transcript <- gsub(pattern = c("shrub|sierra|Sierra|Ciara|ciara|shower|yes") ,replacement = "S", x = transcript)
transcript <- gsub(pattern = c("dad|dead|Dead|delta|Delta") ,replacement = "D", x = transcript)
transcript <- gsub(pattern = c("broadleaf|bravo|Bravo|Bradley") ,replacement = "R", x = transcript)
transcript <- gsub(pattern = c("bear|bare|Bear") ,replacement = "B", x = transcript)
transcript <- gsub(pattern = c("grass|Grass") ,replacement = "B", x = transcript)
transcript <- gsub(pattern = " ",replacement = "",x = transcript)
transcript <- gsub(pattern = "\n",replacement = "",x = transcript)
transcript <- gsub(pattern = "[[:digit:]]",replacement = "",x = transcript)
if(makeCSV == T){
write_csv(x = as.tibble(strsplit(transcript,split = "")[[1]]),file = paste0('~/cloud/gdrive/fire_project/local_data/field_validation/',plotID,"clean_transcript.csv"))
}else{
return(transcript)
}
}
getCSVfromTranscript(file = '~/cloud/gdrive/fire_project/local_data/field_validation/B64_transcript.txt', plotID = "B64",makeCSV = T)