# Set up the PDF output file with A4 paper size pdf("output.pdf", paper = "a4", width = 8.27, height = 11.69) # Write some text with headings cat("Introduction\n") cat("This is a sample document created with R to demonstrate how to write paragraphs with headings.\n\n") cat("Section 1: Background\n") cat("In this section, we provide some background information on the topic of this document.\n\n") cat("Section 2: Methods\n") cat("In this section, we describe the methods used to conduct the research presented in this document.\n\n") cat("Section 3: Results\n") cat("In this section, we present the results of the research and describe their implications.\n\n") cat("Conclusion\n") cat("In conclusion, this document provides a brief overview of the research conducted on this topic.\n\n") # Close the PDF file dev.off()