### Group search terms into concepts (commented example) Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Commented R code showing how to save search terms to a CSV, manually group them, read the grouped CSV, and extract terms for a concept group. This example is not runnable without the CSV file. ```R # write.csv(searchterms, "./search_terms.csv") # manually group terms in the csv # grouped_terms <- read.csv("./search_terms_grouped.csv") # extract the woodpecker terms from the csv # woodpecker_terms <- grouped_terms$term[grep("woodpecker", grouped_terms$group)] # join together a list of manually generated woodpecker terms with the ones from the csv # woodpeckers <- unique(append(c("woodpecker")), woodpecker_terms) # repeat this for all concept groups # then merge them into a list, using the code below as an example # mysearchterms <- list(woodpeckers, fire) ``` -------------------------------- ### Import and deduplicate naive search results with litsearchr Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Imports bibliographic files from a directory using litsearchr::import_results and removes duplicates with litsearchr::remove_duplicates. The example uses system.file() to locate example datasets; for your own files, provide the full path to the directory. The remove_duplicates function is called with field='title' and method='string_osa'. ```R # Note: system.file() is only used to identify where the example datasets are stored # If litsearchr and its dependencies were successfully installed, this directory exists on your computer # If you are using your own bibliographic files, you should not use system.file # You should instead give it the full path (or relative path from your current working directory) to the directory where your files are stored search_directory <- system.file("extdata", package="litsearchr") naiveimport <- litsearchr::import_results(directory = search_directory, verbose = TRUE) #> Reading file /tmp/RtmpGp7mOt/temp_libpath605c6719a3ad/litsearchr/extdata/scopus.ris ... done #> Reading file /tmp/RtmpGp7mOt/temp_libpath605c6719a3ad/litsearchr/extdata/zoorec.txt ... done naiveresults <- litsearchr::remove_duplicates(naiveimport, field = "title", method = "string_osa") ``` -------------------------------- ### Write Boolean search with litsearchr::write_search Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Creates a list of search term groups and passes them to litsearchr::write_search to generate a Boolean search string in English. The example uses stemming, no closure, exact phrase matching, and returns the search string without writing to a file. The output shows the generated search string with wildcards and quotes. ```R # Note: these search terms are a shortened example of a full search for illustration purposes only mysearchterms <- list( c( "picoides arcticus", "black-backed woodpecker", "cavity-nesting birds", "picoides tridactylus", "three-toed woodpecker"), c( "wildfire", "burned forest", "post-fire", "postfire salvage logging", "fire severity", "recently burned" ) ) my_search <- litsearchr::write_search( groupdata = mysearchterms, languages = "English", stemming = TRUE, closure = "none", exactphrase = TRUE, writesearch = FALSE, verbose = TRUE ) #> [1] "English is written" # when writing to a plain text file, the extra \ are required to render the * and " properly # if copying straight from the console, simply find and replace them in a text editor my_search #> [1] "((\"picoid* arcticus*\" OR \"black-back* woodpeck*\" OR \"cavity-nest* bird*\" OR \"picoid* tridactylus*\" OR \"three-to* woodpeck*\") AND (wildfir* OR \"burn* forest*\" OR post-fir* OR \"postfir* salvag* logging\" OR \"fire* sever*\" OR \"recent* burn*\"))" ``` -------------------------------- ### Build keyword co-occurrence network with litsearchr Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Combines extracted keywords, creates a document-feature matrix with create_dfm, and builds a co-occurrence network with create_network. Requires the results from the previous keyword extraction step. The network is built with a minimum of 2 studies and 2 occurrences. ```R all_keywords <- unique(append(taggedkeywords, rakedkeywords)) naivedfm <- litsearchr::create_dfm( elements = paste(naiveresults$title, naiveresults$abstract), features = all_keywords ) naivegraph <- litsearchr::create_network( search_dfm = naivedfm, min_studies = 2, min_occ = 2 ) ``` -------------------------------- ### Import and deduplicate search results with litsearchr::import_results and remove_duplicates Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Imports search results from a directory using litsearchr::import_results and removes duplicate titles using litsearchr::remove_duplicates with the 'string_osa' method. The output shows the files read from the package's extdata directory. ```R results_directory <- system.file("extdata", package="litsearchr") retrieved_articles <- litsearchr::import_results(directory = results_directory, verbose = TRUE) #> Reading file /tmp/RtmpGp7mOt/temp_libpath605c6719a3ad/litsearchr/extdata/scopus.ris ... done #> Reading file /tmp/RtmpGp7mOt/temp_libpath605c6719a3ad/litsearchr/extdata/zoorec.txt ... done retrieved_articles <- litsearchr::remove_duplicates(retrieved_articles, field="title", method="string_osa") ``` -------------------------------- ### Find cutoff and extract search terms with litsearchr Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Uses litsearchr::find_cutoff with method='cumulative' and percent=.80 to determine a cutoff strength, then reduces the graph and extracts keywords. The output shows the first 20 search terms from the reduced graph. ```R cutoff <- litsearchr::find_cutoff( naivegraph, method = "cumulative", percent = .80, imp_method = "strength" ) reducedgraph <- litsearchr::reduce_graph(naivegraph, cutoff_strength = cutoff[1]) searchterms <- litsearchr::get_keywords(reducedgraph) head(searchterms, 20) #> [1] "black hill" "black hills" #> [3] "black-backed woodpecker" "boreal forest" #> [5] "breeding season" "burned forest" #> [7] "cavity nesters" "cavity-nesting birds" #> [9] "certhia americana" "colaptes auratus" #> [11] "conifer forests" "coniferous forest" #> [13] "coniferous forests" "dendroctonus ponderosae" #> [15] "dryocopus pileatus" "fire severity" #> [17] "food availability" "forest management" #> [19] "habitat selection" "habitat suitability" ``` -------------------------------- ### Extract potential keywords with litsearchr::extract_terms Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Uses litsearchr::extract_terms to extract keywords from titles and abstracts (method = "fakerake") and from the keywords field (method = "tagged"). Requires the stopwords namespace. The fakerake method extracts ngrams of length 2 or more, with a minimum frequency of 2. ```R rakedkeywords <- litsearchr::extract_terms( text = paste(naiveresults$title, naiveresults$abstract), method = "fakerake", min_freq = 2, ngrams = TRUE, min_n = 2, language = "English" ) #> Loading required namespace: stopwords taggedkeywords <- litsearchr::extract_terms( keywords = naiveresults$keywords, method = "tagged", min_freq = 2, ngrams = TRUE, min_n = 2, language = "English" ) ``` -------------------------------- ### Check recall with litsearchr::check_recall Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Compares the gold standard titles against the retrieved article titles using litsearchr::check_recall. The output shows a matrix with the gold standard titles, best matches, and similarity scores, indicating which articles were found. ```R articles_found <- litsearchr::check_recall(true_hits = gold_standard, retrieved = retrieved_articles$title) articles_found #> Title #> [1,] "Black-backed woodpecker occupancy in burned and beetle killed forests: disturbance agent matters" #> [2,] "Nest site selection and nest survival of Black-backed Woodpeckers after wildfire" #> [3,] "Cross scale occupancy dynamics of a postfire specialist in response to variation across a fire regime" #> Best_Match #> [1,] "Black-backed woodpecker occupancy in burned and beetle-killed forests: Disturbance agent matters" #> [2,] "Nest site selection and nest survival of Black-backed Woodpeckers after wildfire" #> [3,] "The ecological importance of severe wildfires: Some like it hot" #> Similarity #> [1,] "0.588235294117647" #> [2,] "1" #> [3,] "0.134969325153374" ``` -------------------------------- ### Create gold standard title search with litsearchr::write_title_search Source: https://elizagrames.github.io/litsearchr/litsearchr_vignette.html Defines a gold_standard vector of article titles and uses litsearchr::write_title_search to create a simple search string for those titles. This is used to check if the articles are indexed in bibliographic databases. ```R gold_standard <- c( "Black-backed woodpecker occupancy in burned and beetle killed forests: disturbance agent matters", "Nest site selection and nest survival of Black-backed Woodpeckers after wildfire", "Cross scale occupancy dynamics of a postfire specialist in response to variation across a fire regime" ) title_search <- litsearchr::write_title_search(titles=gold_standard) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.