I want to merge PDF files that already exist (already saved in my computer) using R.
I already tried to use open source softwares to merge them and it works fine bu
If you install pdftk (found here), then you can use the function below:
concatenate_pdfs <- function(input_filepaths, output_filepath) {
  # Take the filepath arguments and format them for use in a system command
  quoted_names <- paste0('"', input_filepaths, '"')
  file_list <- paste(quoted_names, collapse = " ")
  output_filepath <- paste0('"', output_filepath, '"')
  # Construct a system command to pdftk
  system_command <- paste("pdftk",
                          file_list,
                          "cat",
                          "output",
                          output_filepath,
                          sep = " ")
  # Invoke the command
  system(command = system_command)
}
Which could be called as follows:
concatenate_pdfs(input_filepaths = c("My First File.pdf", "My Second File.pdf"),
                 output_filepath = "My Combined File.pdf")
This is just a user-friendly way of invoking the following system command:
pdftk "My First File.pdf" "My Second File.pdf" cat output "My Combined File.pdf"