]> code.communitydata.science - covid19.git/blob - transliterations/analysis/related_searches_example.R
2576d4a862b066423fa6142ee3c53e5dfc4580a3
[covid19.git] / transliterations / analysis / related_searches_example.R
1 ### COVID-19 Digital Observatory
2 ### 2020-03-28
3 ### 
4 ### Minimal example analysis file using trending search data
5
6 ### Identify data source directory and file
7 DataDir <- ("../data/output/")
8 DataFile <- ("related_searches_top.csv")
9
10 ### Import and cleanup data
11 related.searches.top <- read.table(paste(DataDir,DataFile,
12                                  sep=""),
13                            sep=",", header=TRUE,
14                            stringsAsFactors=FALSE) 
15
16 ### Aggregate top 5 search queries by term/day
17 top5.per.term.date <- aggregate(query ~ term + date,
18                                 data=related.searches.top,
19                                 head, 5)
20
21 ## Might cleanup a bit for further analysis or visualization...
22 top5.per.term.date$date <- as.Date(top5.per.term.date$date)
23
24 ### Export
25 write.table(top5.per.term.date,
26             file="output/top5_queries_per_term_per_date.csv", sep=",",
27             row.names=FALSE)
28

Community Data Science Collective || Want to submit a patch?