as.ft_data: Coerce directory of papers to ft_data object

Description Usage Arguments Details Value See Also Examples

View source: R/as.ft_data.R

Description

create the same object that ft_get() outputs from your cached files - without having to run ft_get() again

Usage

1
as.ft_data(path = NULL)

Arguments

path

cache path. if not given, we use the default cache path. Default: NULL

Details

We use an internal store of identifiers to keep track of files. These identifiers are in the output of ft_get() and you can see them in that output. If a file does not have a matching entry in our index of files (e.g., if you drop a file into the cache location as in the example below), then we assign it an index based on the file path; we'd ideally use an article DOI or similar but we can not safely retrieve it with just a file path.

Value

an object of class ft_data

See Also

ft_get()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# put a file in the cache in case there aren't any
dir <- file.path(tempdir(), "testing")
dir.create(dir)
file <- system.file("examples", "elife.xml", package = "fulltext")
writeLines(readLines(file), tempfile(tmpdir = dir, fileext = ".xml"))

# call as.ft_data
x <- as.ft_data(path = dir)

# output lives underneath a special list index "cached" 
#   representing already present files
x$cached

## Not run: 
# collect chunks
if (requireNamespace("pubchunks")) {
  library(pubchunks)
  res <- ft_collect(x)
  pub_chunks(res, c("doi", "title")) %>% pub_tabularize()
}

## End(Not run)

fulltext documentation built on June 12, 2021, 9:06 a.m.