search_results_export {act} | R Documentation |
Exports search results
Description
Search results from a search object will be saved to a Excel-XLSX or a CSV (comma separated values) file.
By default a XLSX file will be saved. If you want to save a CSV file, use saveAsCSV=TRUE
.
Please note:
The function will '=' signs at the beginning of annotation by ".=". This is because the content would be interpreted as the beginning of a formula (leading to an error).
In the case of writing to an excel file, line breaks will be replaced by "|". This is because line breaks will lead to an error.
Usage
search_results_export(
s,
path,
sheetNameXLSX = "data",
saveAsCSV = FALSE,
encodingCSV = "UTF-8",
separatorCSV = ";",
overwrite = TRUE
)
Arguments
s |
Search object. Search object containing the results you wish to export. |
path |
Character string; path where file will be saved. Please add the suffix '.csv' or '.xlsx' to the file name. |
sheetNameXLSX |
Character string, set the name of the excel sheet. |
saveAsCSV |
Logical; if |
encodingCSV |
Character string; text encoding for CSV files. |
separatorCSV |
Character; single character that is used to separate the columns. |
overwrite |
Logical; if |
Examples
library(act)
# Search
mysearch <- act::search_new(examplecorpus, pattern="yo")
nrow(mysearch@results)
# Create temporary file path
path <- tempfile(pattern = "searchresults", tmpdir = tempdir(),
fileext = ".xlsx")
# It makes more sense, however, to you define a destination folder
# that is easier to access on your computer:
## Not run:
path <- tempfile(pattern = "searchresults",
tmpdir = "PATH_TO_AN_EXISTING_FOLDER_ON_YOUR_COMPUTER",
fileext = ".xlsx")
## End(Not run)
# Save search results
act::search_results_export(s=mysearch, path=path)
# Do your coding of the search results somewhere outside of act
# ...
# Load search results
mysearch.import <- act::search_results_import(path=path)
nrow(mysearch.import@results)