Learn R Programming

LexisNexisTools (version 0.2.2)

lnt_rename: Assign proper names to LexisNexis TXT files

Description

Give proper names to TXT files downloaded from 'LexisNexis' based on search term and period retrieved from each file cover page. This information is not always delivered by LexisNexis though. If the information is not present in the file, new file names will be empty.

Usage

lnt_rename(x, encoding = "UTF-8", recursive = FALSE, report = TRUE,
  simulate = TRUE, verbose = FALSE)

Arguments

x

Can be either a character vector of LexisNexis TXT file name(s), folder name(s) or can be left blank (see example).

encoding

Encoding to be assumed for input files. Defaults to UTF-8 (the LexisNexis standard value).

recursive

A logical flag indicating whether subdirectories are searched for more TXT files.

report

A logical flag indicating whether the function will return a report which files were renamed.

simulate

Should the renaming be simulated instead of actually done? This can help prevent accidental renaming of unrelated TXT files which happen to be in the same directory as the files from 'LexisNexis'.

verbose

A logical flag indicating whether information should be printed to the screen.

Details

Warning: This will rename all TXT files in a give folder.

Examples

Run this code
# NOT RUN {
# Copy sample file to current wd
lnt_sample()

# Rename files in current wd and report back if successful
 
# }
# NOT RUN {
report.df <- lnt_rename(recursive = FALSE,
                        report = TRUE)
# }
# NOT RUN {
# Or provide file name(s)
my_files<-list.files(pattern = ".txt", full.names = TRUE,
                     recursive = TRUE, ignore.case = TRUE)
report.df <- lnt_rename(x = my_files,
                        recursive = FALSE,
                        report = TRUE)

# Or provide folder name(s)
report.df <- lnt_rename(x = getwd())

report.df
# }

Run the code above in your browser using DataLab