I am trying to zip multiple CSV files in R. Below is the code for reference.
# Create two dataframes using inbuilt datasets for reproducible code
df1 <- head(mtcars)
df2 <- head(iris)
# Write the files as CSV into working directory
write.csv(df1, file = "Test_File1.csv", row.names = FALSE, quote = FALSE)
write.csv(df2, file = "Test_File2.csv", row.names = FALSE, quote = FALSE)
# Read the 2 CSV file names from working directory
Zip_Files <- list.files(path = getwd(), pattern = ".csv$")
# Zip the files and place the zipped file in working directory
zip(zipfile = "TestZip", files = Zip_Files)
I am getting the below warning message. The Zip file has not been created.
Warning message:
running command '"zip" -r9X "TestZip" "Test_File1.csv" "Test_File2.csv" ' had status 127
I even tried this command to read CSV file names: Zip_Files <- list.files(path = getwd(), pattern = ".csv$", full.names = TRUE)
But I still get the warning message shown above. I already have WinRAR
and 7-Zip
installed in my computer. I am using the latest version of R (3.4.2 64 Bit) along with latest version of RStudio. I have a Windows 7 x64 OS. Any help on this would be really appreciated.