Open CSV file in excel from R script

I have generated a csv file in R and would like my script to open this file in excel so that someone with no knowledge of R can modify the data. (Ideally when I run the script excel opens and loads this file). What is the best way to accomplish this?

1 answer

  • answered 2018-01-17 02:30 conor

    The cmd command to open an excel file is open excel file.xlsx. In R you can run the command line using system. So putting these together:

    excel_file_with_path <- "C:/Users/myusername/Documents/file.xlsx"
    command <- paste("open excel", excel_file_with_path)