Chapter 14 文献计量研究案例

案例14.1 语音感知文献计量研究

详细背景请看原文献

详细背景请看原文献

研究背景

研究问题及假设

研究结果

数据可视化与展示

   语音感知研究中最活跃的20所大学/研究机构及其合作网络。网络中的每个节点代表一个不同的大学/研究机构,节点的直径与该机构与其他机构的合作强度成正比。节点之间的连线表示这些大学或研究机构之间的合作路径。

  语音感知研究中前20个国家的合作网络。

  网络中的每个节点代表一个不同的国家,节点的直径与该国家与其他国家合作的强度成正比。节点之间的连线表示国家之间的合作路径。

   语音感知研究的共引网络。节点代表研究文章。每个节点的标签颜色与其所在的集群相同,节点的大小与其共引度成正比。

  语音感知研究的文献耦合网络,其中节点代表研究文章。每个节点的标签颜色与其所在的集群相同,节点的大小与其文献耦合度成正比。

  前20个作者定义关键词、机器生成关键词、基于标题和摘要的两词短语(Freq = 频率)注意:在论文表格中,一些术语进行了合并处理,例如在标题两词短语列中,“Cochlear implant”(人工耳蜗)和“cochlear implantation”(人工耳蜗植入)被合并。

stop.words = c("elsevier","rights reserved","NA NA",
               "results suggest","experiment 1","speech perception",
               "experiment 2","NA","NA")

# no temporal variation
au.ky = speech.data%>%
  select(DE,PY)%>%
  transform(DE = strsplit(DE, ";")) %>%
  unnest(DE)%>%
  filter(!DE%in%c("SPEECH PERCEPTION","SPEECH",
                  "PERCEPTION", " SPEECH"," SPEECH PERCEPTION",
                  " PERCEPTION"," LANGUAGE", "LANGUAGE"))%>%
  filter(DE != "" & !is.na(DE))%>%
  mutate(DE = str_replace_all(DE, " ",""),
         DE = str_replace_all(DE, "-",""),
         DE = str_to_title(DE),
         DE = dplyr::recode(DE, "Cochlearimplants" = "Cochlearimplant"),)%>%
  count(DE, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 25)%>%
  select(-order)%>%
  rename(AuthorKeywords= DE,
         AuFreq = n)

# write.csv(au.ky, 
#           file =  paste("au.ky",
#                              Sys.Date(),
#                              "csv",
#                              sep = ".") ,row.names = FALSE)

# No temporal variation
machine.ky = speech.data%>%
  select(ID,PY)%>%
  transform(ID = strsplit(ID, ";")) %>%
  unnest(ID)%>%
  filter(!ID%in%c("SPEECH PERCEPTION","SPEECH",
                  "PERCEPTION", " SPEECH"," SPEECH PERCEPTION",
                  " PERCEPTION"," LANGUAGE", "LANGUAGE", 
                  "SPEECH-PERCEPTION", " SPEECH-PERCEPTION"))%>%
  filter(ID != "" & !is.na(ID))%>%
  mutate(ID = str_replace_all(ID, " ",""),
         ID = str_replace_all(ID, "-",""),
         ID = str_to_title(ID),
         ID = dplyr::recode(ID, "Cochlearimplants" = "Cochlearimplant"))%>%
  count(ID, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 25)%>%
  select(-order)%>%
  rename(MachineKeywords= ID,
         MFreq = n)


# title 2-gram
title.ky.2gram = speech.data%>%
  select(TI,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(bigram, TI, 
                to_lower = T,
                token = "ngrams", n = 2)%>%
  separate(bigram, c("word1", "word2"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  filter(!word2 %in% stop_words$word, !word2 %in% stop.words)%>%
  unite(bigram, word1, word2, sep = " ")%>%
  filter(!bigram%in% stop.words)%>%
  mutate(bigram = str_replace_all(bigram, " ",""),
         #ID = str_replace_all(ID, "-",""),
         bigram = str_to_title(bigram),
         bigram = dplyr::recode(bigram, "Cochlearimplants" = "Cochlearimplant"))%>%
  count(bigram,sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order<25)%>%
  select(-order)%>%
  rename(Title2gram= bigram,
         TFreq = n)

# write.csv(title.ky.2gram, 
#           file =  paste("title.ky.2gram",
#                              Sys.Date(),
#                              "csv",
#                              sep = ".") ,row.names = FALSE)


# no temporal variation
ab.ky.2gram = speech.data%>%
  select(AB,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(bigram, AB, 
                to_lower = T,
                token = "ngrams", n = 2)%>%
  separate(bigram, c("word1", "word2"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  filter(!word2 %in% stop_words$word, !word2 %in% stop.words)%>%
  unite(bigram, word1, word2, sep = " ")%>%
  filter(!bigram%in% stop.words)%>%
  count(bigram, sort = TRUE)%>%
  mutate(bigram = str_replace_all(bigram, " ",""),
         #ID = str_replace_all(ID, "-",""),
         bigram = str_to_title(bigram),
         bigram = dplyr::recode(bigram, "Cochlearimplants" = "Cochlearimplant"))%>%
  mutate(order = 1:n())%>%
  filter(order<25)%>%
  select(-order)%>%
  rename(Abstract2gram= bigram,
         ABFreq = n)

# write.csv(ab.ky.2gram, 
#           file =  paste("ab.ky.2gram",
#                              Sys.Date(),
#                              "csv",
#                              sep = ".") ,row.names = FALSE)

term.freq = au.ky%>%
  bind_cols(machine.ky, title.ky.2gram, ab.ky.2gram)

knitr::kable(term.freq)

作者自定义词网络

案例14.2 神经语言学文献计量研究

详细背景请看原文献

详细背景请看原文献

研究背景

研究问题及假设

研究结果

描述性数据展示

## 基于期刊文献标题的核心研究主题
# stop.words = c("elsevier","rights reserved","NA NA","taylor francis","taylor",
#                "francis","psychology press","uk limited","copyright","informa",
#                "results results", "limited trading","outcomes results",
#                   "methods procedures",
#                "results suggest","experiment 1",
#                "experiment 2","NA","NA")

stopWords <- read_csv("data/ch14/stopWords.csv", col_names = FALSE)

stop.words = as.vector(stopWords$X1)

# keywords
au.ky = neuro.bib%>%
  select(DE,PY)%>%
  transform(DE = strsplit(DE, ";")) %>%
  unnest(DE)%>%
  filter(DE != "" & !is.na(DE))%>%
  mutate(DE = str_replace_all(DE, "^ ",""),
         DE = str_replace_all(DE, "-","_"),
         DE = str_to_title(DE),
         DE = recode(DE, "Primary Progressive Aphasia" = "PPA"),
         )%>%
  filter(!DE%in%c("Aphasia","Language"))%>%
  count(DE, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 101)%>%
  select(-order)%>%
  rename(AuthorKeywords= DE,
         AuFreq = n)

write.csv(au.ky,
          file = paste(tbl.fig,
                       paste("au.100.keyword",
                             Sys.Date(),
                             "csv",
                             sep = "."),
                       sep = "") ,row.names = FALSE)

authorkeyword.coc <- biblioNetwork(neuro.meta, 
                         analysis = "co-occurrences",  
                         network = "author_keywords", 
                         sep = ";")

authorkeyword.coc.plt = networkPlot(authorkeyword.coc ,
                n = 40,
                Title = "神经语言学论文作者关键词共现网络",
                type = "fruchterman",
                size=10, size.cex=T,curved=TRUE, 
                remove.multiple=F,
                label.n = 20,
                edgesize = 3,
                #edges.min = 15,
                labelsize=1 ,
                # plot or not
                verbose = FALSE)

png(paste(tbl.fig,
           paste("authorkeyword.coc.plt",
                 Sys.Date(),
                 "png",
                 sep = "."),
           sep = ""),
     units="in", width=8, height=8, res=600)

plot(authorkeyword.coc.plt$graph)

dev.off()
## 基于期刊文献关键词的核心研究主题

# title
title.word = neuro.bib%>%
  # filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(TI,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(word, TI, 
                to_lower = T,
                token = "words")%>%
  filter(!word %in% stop_words$word, !word %in% stop.words) %>%
  filter(!word %in% c("aphasia","aphasic","patient","study",
                      "people","language"))%>%
  count(word, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 51)

title.2gram = neuro.bib%>%
  # filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(TI,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
    unnest_tokens(bigram, TI, 
                to_lower = T,
                token = "ngrams", n = 2)%>%
  separate(bigram, c("word1", "word2"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  filter(!word2 %in% stop_words$word, !word2 %in% stop.words)%>%
  unite(bigram, word1, word2, sep = " ")%>%
  filter(!bigram%in% stop.words)%>%
  count(bigram, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 51)

title.3gram = neuro.bib%>%
  # filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(TI,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(trigram, TI, 
                to_lower = T,
                token = "ngrams", n = 3)%>%
  separate(trigram, c("word1", "word2", "word3"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  #filter(!word2 %in% stop_words$word, !word2 %in% stop.words)%>%
  filter(!word3 %in% stop_words$word, !word3 %in% stop.words)%>%
  unite(trigram, word1, word2, word3, sep = " ")%>%
  filter(!trigram%in% stop.words)%>%
  count(trigram, sort = TRUE)%>%
  mutate(order = 1:n())%>%
  filter(order < 51)

title.all = cbind(title.word, title.2gram, title.3gram)

write.csv(title.all,
          file = paste(tbl.fig,
                       paste("title.50.keyword",
                             Sys.Date(),
                             "csv",
                             sep = "."),
                       sep = "") ,row.names = FALSE)

neuro.meta$TI_TM = neuro.meta$TI
title.coc <- biblioNetwork(neuro.meta, 
                         analysis = "co-occurrences",  
                         network = "titles", 
                         sep = ";")

title.coc.plt = networkPlot(title.coc ,
                n = 40,
                Title = "神经语言学论文标题关键词共现网络",
                type = "sphere",
                size=10,size.cex=T,
                remove.multiple=F,
                label.n = 20,
                edgesize = 3,labelsize=0.6,
                # plot or not
                verbose = FALSE)

png(paste(tbl.fig,
           paste("authorkeyword.coc.plt",
                 Sys.Date(),
                 "png",
                 sep = "."),
           sep = ""),
     units="in", width=4, height=4, res=600)

plot(title.coc.plt$graph)

dev.off()



# library(wordcloud)
# jpeg(paste(tbl.fig, 
#            paste("AuthorKeywords",
#                  Sys.Date(),
#                  "jpeg",
#                  sep = "."), 
#            sep = ""),
#      units="in", width=8, height=4, res=600)
# 
# wordcloud(words = au.ky$AuthorKeywords, freq = au.ky$AuFreq, min.freq = 1,
#           max.words=200, random.order=FALSE, rot.per=0.35, 
#           colors=brewer.pal(8, "Dark2"))
# dev.off()
# 
# jpeg(paste(tbl.fig, 
#            paste("title.1gram",
#                  Sys.Date(),
#                  "jpeg",
#                  sep = "."), 
#            sep = ""),
#      units="in", width=8, height=4, res=600)
# 
# wordcloud(words = title.word$word, freq = title.word$n, min.freq = 1,
#           max.words=200, random.order= T, rot.per=0.35, 
#           colors=brewer.pal(8, "Dark2"))
# dev.off()
# 
# jpeg(paste(tbl.fig, 
#            paste("title.2gram",
#                  Sys.Date(),
#                  "jpeg",
#                  sep = "."), 
#            sep = ""),
#      units="in", width=8, height=4, res=600)
# 
# wordcloud(words = title.2gram$bigram, freq = title.2gram$n, min.freq = 1,
#           max.words=200, random.order= T, rot.per=0.35, 
#           colors=brewer.pal(8, "Dark2"))
# dev.off()
# 
# jpeg(paste(tbl.fig, 
#            paste("title.3gram",
#                  Sys.Date(),
#                  "jpeg",
#                  sep = "."), 
#            sep = ""),
#      units="in", width=8, height=4, res=600)
# 
# wordcloud(words = title.3gram$trigram, freq = title.3gram$n, min.freq = 1,
#           max.words=200, random.order= T, rot.per=0.35, 
#           colors=brewer.pal(8, "Dark2"))
# dev.off()
## 基于期刊摘要的核心研究主题变化趋势


# abstract

ab.1gram = neuro.bib%>%
  filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(AB,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(word, AB, 
                to_lower = T,
                token = "words")%>%
  filter(!word %in% stop_words$word, 
         !word %in% stop.words) %>%
  count(word, sort = TRUE)%>%
  filter(!word %in% c("aphasia","aphasic","patient","study","results","background",
                      "outcomes",
                      "people","language"))%>%
  filter(n>20)%>%
  mutate(order = 1:n(),
         type = "monogram")%>%
  rename(topic = word)%>%
  filter(!topic %in% as.character(c(1:10000)))

ab.2gram = neuro.bib%>%
  filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(AB,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(bigram, AB, 
                to_lower = T,
                token = "ngrams", n = 2)%>%
  separate(bigram, c("word1", "word2"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  filter(!word2 %in% stop_words$word, !word2 %in% stop.words)%>%
  unite(bigram, word1, word2, sep = " ")%>%
  filter(!bigram%in% stop.words)%>%
  count(bigram, sort = TRUE)%>%
  filter(n>20)%>%
  mutate(order = 1:n(),
         type = "bigram")%>%
  rename(topic = bigram)

ab.3gram = neuro.bib%>%
  filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(AB,PY)%>%
  tibble::rownames_to_column(., "paper")%>%
  unnest_tokens(trigram, AB, 
                to_lower = T,
                token = "ngrams", n = 3)%>%
  separate(trigram, c("word1", "word2", "word3"), sep = " ")%>%
  filter(!word1 %in% stop_words$word, !word1 %in% stop.words) %>%
  filter(!word2 %in% stop.words)%>%
  filter(!word3 %in% stop_words$word, !word3 %in% stop.words)%>%
  unite(trigram, word1, word2, word3, sep = " ")%>%
  filter(!trigram%in% stop.words)%>%
  count(trigram, sort = TRUE)%>%
  filter(n>20)%>%
  mutate(order = 1:n(),
         type = "trigram")%>%
  rename(topic = trigram)


all.topics = rbind(ab.1gram, ab.2gram, ab.3gram)%>%
  select(topic)%>%
  as.vector()

#### normalising frequency

# get artile numbers
n.article =neuro.bib%>%
  filter(AB != "[NO ABSTRACT AVAILABLE]")%>%
  select(TI,PY, AB)%>%
  mutate(removed = str_detect(TI, "ERRATUM"),
         uniqueID = as.character(1:n()))%>%
  filter(removed != TRUE)%>%
  mutate(period =case_when(
    PY %in% 1974:1999 ~ "first",
    PY %in% 2000:2010 ~ "second",
    PY %in% 2011:2023 ~ "third" ))%>%
  group_by(period)%>%
  mutate(n.paper = n())


neuro.bib.corpus = corpus(n.article, 
                        text_field = "AB",
                        docid_field = "uniqueID",
               meta = list(source = "Aphasiology"))

head(summary(neuro.bib.corpus))

# identify each monogram, bigram, trigram
df = kwic(tokens(neuro.bib.corpus), pattern = phrase(all.topics$topic))

library(rstatix)

topic.df = df%>%
  left_join(n.article, by = c("docname" = "uniqueID"))%>%
  group_by(docname, period, n.paper)%>%
  distinct(pattern)%>%
  group_by(period, n.paper)%>%
  count(pattern, sort = TRUE)%>%
  mutate(norm.freq = round(1000*(n/n.paper)),0)%>%
  ungroup()%>%
  select(pattern, period, norm.freq)%>%
  spread(period, norm.freq)%>%
  # fill all na with 0
  replace(is.na(.), 0)%>%
  gather("period", "norm.freq","first","second","third")%>%
  group_by(pattern)%>%
  mutate(sum = sum(norm.freq))%>%
  filter(sum != 0)
  

# 整理提取统计值
library(broom)
options(scipen = 999)
topic.test =  topic.df%>%
  group_by(pattern)%>%
  summarise(res = list(
    tidy(
      chisq.test(norm.freq))))%>%
    unnest()

topic.wide.df = df%>%
  left_join(n.article, by = c("docname" = "uniqueID"))%>%
  group_by(period, n.paper)%>%
  count(pattern, sort = TRUE)%>%
  mutate(norm.freq = round(1000*(n/n.paper)),0)%>%
  ungroup()%>%
  select(pattern, period, norm.freq)%>%
  spread(period, norm.freq)%>%
  # fill all na with 0
  replace(is.na(.), 0)


topic.results = topic.test%>%
  filter(p.value<0.05)%>%
  select(pattern, statistic, p.value)%>%
  left_join(topic.wide.df)%>%
  mutate(pattern = as.character(pattern))%>%
  filter(!pattern%in%c("uk","trading","limited","rights","llc","pwa",
                       "research","author",
                       "participant","aim","participation","persons",
                       "reserved","press"))%>%
  mutate(topic.len = str_count(pattern, pattern = " "),
         topic.len = as.character(topic.len))%>%
  mutate(trends = case_when(first < second & second < third ~ "rise",
                            first < second & second == third ~ "rise_level",
                            first == second & second < third ~ "level_rise",
                            first > second & second > third ~ "decrease",
                            first > second & second == third ~ "decrease_level",
                            first == second & second > third ~ "level_decrease",
                            first < second & second > third ~ "peak",
                            first > second & second < third ~ "valley"))%>%
  group_by(topic.len, trends)%>%
  arrange(desc(p.value))%>%
  arrange(p.value)%>%
  mutate(order = 1:n())

topic.top50 =topic.results %>%
                        filter(order < 51)%>%
  select(trends,topic.len, pattern, order, first, second, third)%>%
  group_by(trends,topic.len)%>%
  arrange(order)


# write.csv(topic.top50 , 
#           file = paste(tbl.fig, 
#                        paste("topic.top50",
#                              Sys.Date(),
#                              "csv",
#                              sep = "."),
#                        sep = "") ,row.names = FALSE)

# rising trend
trend.rise = topic.top50 %>%
  filter(trends %in% c("rise","rise_level","level_rise"))%>%
  filter(!pattern %in% c("hr","pwas","studies","support","participants","future","imprint","business",
                         "published","identified","completed","impact","examine","explore","improve","aimed",
                         "contribution","including","investigate","key","conclusion","speech and language",
                         "primary outcome","add","relationship","extent",
                         "people with aphasia",
                         "persons with aphasia","individuals with aphasia","outcomes and results",
                         "methods and procedures","participants with aphasia","patients with aphasia",
                         "data were collected","data were analysed",
                         "procedures"))%>%
  mutate(pattern = recode(pattern, "slts" = "speech-language therapists",
                          "cps" = "conversation paterners",
                          "anelt" ="Amsterdam Nijmegen Everyday Language Test",
                          "icap" ="Intensive Comprehensive Aphasia Program",
                          "lvppa"="Logopenic Variant Of Primary Progressive Aphasia",
                          "nfvppa" = "Non-fluent Variant Of Primary Progressive Aphasia",
                          "svppa" = "Semantic Variant Of Primary Progressive Aphasia",
                          "tdcs" = "TRANSCRANIAL DIRECT CURRENT STIMULATION",
                          "tms" = "TRANSCRANIAL MAGNETIC STIMULATION",
                          "ppa"= "Primary Progressive Aphasia",
                          "slps" = "SPEECH-LANGUAGE PATHOLOGISTS",
                          "cpt" = "COMMUNICATION PARTNER TRAINING",
                          "stm" = "SHORT-TERM MEMORY"))%>%
    mutate(topic.len = str_count(pattern, pattern = " ") + 1,
           topic.len = as.character(topic.len),
           pattern = tolower(pattern))%>%
  arrange(trends, topic.len)
  
write.csv(trend.rise ,
          file = paste(tbl.fig,
                       paste("trend.rise",
                             Sys.Date(),
                             "csv",
                             sep = "."),
                       sep = "") ,row.names = FALSE)

# falling trend
trend.decrease = topic.top50 %>%
  filter(trends %in% c("decrease","decrease_level","level_decrease"))%>%
  filter(!pattern %in% c("hr","pwas","studies","support","participants","future","imprint","business",
                         "published","identified","completed","impact","examine","explore","improve","aimed",
                         "contribution","including","investigate","key","conclusion","speech and language",
                         "primary outcome","add","relationship","extent",
                         "people with aphasia",
                         "persons with aphasia","individuals with aphasia","outcomes and results",
                         "methods and procedures","participants with aphasia","patients with aphasia",
                         "data were collected","data were analysed",
                         "procedures"))%>%
  mutate(pattern = recode(pattern, "slts" = "speech-language therapists",
                          "cps" = "conversation paterners",
                          "anelt" ="Amsterdam Nijmegen Everyday Language Test",
                          "icap" ="Intensive Comprehensive Aphasia Program",
                          "lvppa"="Logopenic Variant Of Primary Progressive Aphasia",
                          "nfvppa" = "Non-fluent Variant Of Primary Progressive Aphasia",
                          "svppa" = "Semantic Variant Of Primary Progressive Aphasia",
                          "tdcs" = "TRANSCRANIAL DIRECT CURRENT STIMULATION",
                          "tms" = "TRANSCRANIAL MAGNETIC STIMULATION",
                          "ppa"= "Primary Progressive Aphasia",
                          "slps" = "SPEECH-LANGUAGE PATHOLOGISTS",
                          "cpt" = "COMMUNICATION PARTNER TRAINING",
                          "stm" = "SHORT-TERM MEMORY"))%>%
    mutate(topic.len = str_count(pattern, pattern = " ") + 1,
           topic.len = as.character(topic.len),
           pattern = tolower(pattern))%>%
  arrange(trends, topic.len)

write.csv(trend.decrease ,
          file = paste(tbl.fig,
                       paste("trend.decrease",
                             Sys.Date(),
                             "csv",
                             sep = "."),
                       sep = "") ,row.names = FALSE)


trend.peak.valley = topic.top50 %>%
  filter(trends %in% c("peak","valley"))%>%
  filter(!pattern %in% c("hr","pwas","studies","support","participants","future","imprint","business",
                         "published","identified","completed","impact","examine","explore",
                         "improve","aimed",
                         "contribution","including","investigate","key","conclusion","speech and language",
                         "primary outcome","add","relationship","extent",
                         "people with aphasia",
                         "persons with aphasia","individuals with aphasia","outcomes and results",
                         "methods and procedures","participants with aphasia","patients with aphasia",
                         "data were collected","data were analysed",
                         "procedures",
                         "psychology","al","total","methods","purpose",
                         "aphasic individuals","aphasic speakers",
                         "person with aphasia","individual with aphasia","individual with aphasia",
                         "patients","variant","characterized","analyzed"))%>%
  mutate(pattern = recode(pattern, "slts" = "speech-language therapists",
                          "cps" = "conversation paterners",
                          "anelt" ="Amsterdam Nijmegen Everyday Language Test",
                          "icap" ="Intensive Comprehensive Aphasia Program",
                          "lvppa"="Logopenic Variant Of Primary Progressive Aphasia",
                          "nfvppa" = "Non-fluent Variant Of Primary Progressive Aphasia",
                          "svppa" = "Semantic Variant Of Primary Progressive Aphasia",
                          "tdcs" = "TRANSCRANIAL DIRECT CURRENT STIMULATION",
                          "tms" = "TRANSCRANIAL MAGNETIC STIMULATION",
                          "ppa"= "Primary Progressive Aphasia",
                          "slps" = "SPEECH-LANGUAGE PATHOLOGISTS",
                          "cpt" = "COMMUNICATION PARTNER TRAINING",
                          "stm" = "SHORT-TERM MEMORY"))%>%
    mutate(topic.len = str_count(pattern, pattern = " ") + 1,
           topic.len = as.character(topic.len),
           pattern = tolower(pattern))%>%
  arrange(trends, topic.len)

write.csv(trend.peak.valley,
          file = paste(tbl.fig,
                       paste("trend.peak.valley",
                             Sys.Date(),
                             "csv",
                             sep = "."),
                       sep = "") ,row.names = FALSE)