This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Compiling several text files into a single CSV file | |
#' | |
#' Convert a folder of text files into a single CSV file | |
#' with one column for the file names and one column of the | |
#' text of the file. A function in R. | |
#' | |
#' To use this function for the first time run this next line: | |
#' install.packages("devtools") | |
#' then thereafter you just need to load the function | |
#' fom github like so, with these two lines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test it by creating some small text files to run the function on | |
txt <- c("here is", "some text", "to test", "this function with", "'including a leading quote", '"and another leading quote') | |
# make text files | |
dir.create("testdir") | |
for(i in 1:length(txt)){ | |
writeLines(txt[i], paste0("testdir/outfile-", i, ".txt")) | |
} | |
# run the function and then look in the CSV file that is produced. |