-
Notifications
You must be signed in to change notification settings - Fork 0
/
summarise.R
37 lines (29 loc) · 1014 Bytes
/
summarise.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
## config import
library(rstudioapi)
source(paste0(dirname(rstudioapi::getSourceEditorContext()$path),"/config.R"))
letterfiles <- paste0(letteraggregatedfolder, list.files(letteraggregatedfolder))
## libraries
library(data.table)
library(dplyr)
library(magrittr)
## functions definition
summarisation <- function(file,exportfilename){
load(file)
print(paste(exportfilename,"- file loaded"))
totalfrequences <- totalfrequences %>%
group_by(words) %>%
summarise_all(funs(mean(count,na.rm=TRUE)))
print(paste(exportfilename,"- file summarised"))
totalpathname <- paste0(summarisedfolder,exportfilename)
save(totalfrequences,file=totalpathname)
print(paste(exportfilename,"- file saved"))
}
lettercaller <- function(){
for (i in 1:length(letters)){
print(paste("calling summarisation for letter",letters[i]))
summarisation(letterfiles[i],letters[i])
print(paste("letter",letters[i],"summarised"))
}
}
## function call
lettercaller()