I'm trying to output my analysis from my R code through multiple write-commands as mentioned below. However, I am getting only one last line output to my text file.
Code:
# Create a report file
report_file <- file("XYZ.txt")
# Write findings to the report file
writeLines("Report on Weather Analysis\n", report_file)
writeLines("\n3. Correlations between Weather Conditions and Departure Delays\n", report_file)
writeLines(paste("Correlation between Average Wind Speed and Departure Delays:", correlation_wind_speed), report_file)
writeLines(paste("Correlation between Wind Gust and Departure Delays:", correlation_wind_gust), report_file)
writeLines(paste("Correlation between Precipitation and Departure Delays:", correlation_precipitation), report_file)
# Close the report file
close(report_file)
I have also added the output provided through above lines of code from the text file.enter image description here
I am getting only one last line output to my text file. I need all my writeLines details in the output file. Please advice, if anyone has any expertise in this regards? Thanks in advance.